Hey Cats,
I'm having a problem. I'm working with an object that contains a bunch
of arrays:

var myObject = {
   "data": [
      {"line": [1,"aoo","far"]},
      {"line": [2,"boo","ear"]},
      {"line": [3,"coo","dar"]},
      {"line": [4,"doo","car"]},
      {"line": [5,"eoo","bar"]},
      {"line": [6,"foo","aar"]}
   ]
};

I'd like to be able to sort across the arrays. so that the objects in
the "data" array rearange themselves based on what column of the
"line" arrays are sorted. So for instance if I wanted to sort on 
myObject.data.line[2] the object would rearrange itself to look like:

var myObject = {
   "data": [
      {"line": [6,"foo","aar"]},
      {"line": [5,"eoo","bar"]},
      {"line": [4,"doo","car"]},
      {"line": [3,"coo","dar"]},
      {"line": [2,"boo","ear"]},
      {"line": [1,"aoo","far"]}
   ]
};

It seems like I should be able to use the collect method in prototype
to achieve this, but I can't quite wrap my head around how. :) If
anyone has any advice that would be great. Thanks in advance.

- J
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to