I think this would do it:
var json = "{1:'something', 2: 'A lovely thing', 3:'Not so nice'}"
var compare_items = function(a, b){
return compare(a[1], b[1])
}
var sort_options = function(options) {
return sorted(items(options), compare_items)
}
var opts = eval('(' + json + ')')
var s = sort_options(opts)
assert ( objEqual(s ,[[2, 'A lovely thing'], [3,'Not so nice'],
[1,'something']] ));
There is probably a way to use map to make this more compact, but its
pretty easy to see what's going on above. At least that's my excuse. :-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---