Hi Folks,
I wondered if there was a way to sort a JSON array. Here's an
example:
var RS = [
{id: 1, dateFrom: 20090101, dateTo: 20090309, tariff: [
{guest: 1, mon: 105, tue: 79, wed: 79, thu: 79, fri: 99, sat: 109,
sun: 79},
{guest: 2, mon: 89, tue: 89, wed: 89, thu: 89, fri: 109, sat: 119,
sun: 89}
]},
{id: 2, dateFrom: 20090302, dateTo: 20090304, tariffhigh: 180,
tarifflow: 150, tariff: [
{guest: 1, mon: 240, tue: 0, wed: 0, thu: 0, fri: 0, sat: 0, sun:
0},
{guest: 2, mon: 220, tue: 0, wed: 0, thu: 0, fri: 0, sat: 0, sun: 0}
]},
{id: 0, dateFrom: 20081216, dateTo: 20081216, tariff: [
{guest: 1, mon: 0, tue: 0, wed: 0, thu: 0, fri: 0, sat: 0, sun: 0}
]}
]
RS.sortBy(function(i){return i.dateFrom},this)
I've simplified this code slightly but you should get the general
idea.
I'm trying to reorder by dateFrom but I can't get sortBy to sort in
this case. Anyone know what I'm doing wrong, or is there an
altogether better way?
Many thanks
George
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---