I have the following data:
var data = [[{x:"c", y:10}, {x:"a", y:20}, {x:"b", y:4}], [{x:"c", y:14}, {x:"a", y:22}, {x:"b", y:9}], [{x:"c", y:24}, {x:"a", y:65}, {x:"b", y:46}]]
I need to order the (x) element of each array (within the parent array) based on the value of the 'y' attributes from the last array element. The result would be:
[[{x:"c", y:10}, {x:"b", y:4}, {x:"a", y:20}], [{x:"c", y:14}, {x:"b", y:9}, {x:"a", y:22}], [{x:"c", y:24}, {x:"b", y:46}, {x:"a", y:65}]]
Any easy way to do that? Here's the global structure of the data:
var data = [[{x:"x_1", y:}, {x:"x_2", y:},.. {x:"x_N", y:}], [{x:"x_1", y:}, {x:"x_2", y:},.. {x:"x_N", y:}], [{x:"x_1", y:}, {x:"x_2", y:},.. {x:"x_N", y:}]]
I have an array of 3 arrays that each contains N hash tables.
I need to order the elements in all hash tables based on the values of the 'y' key from the last element (data[2]).