In Ruby how do you sort one multi dimendional array by another multi dimensional array?

Posted by Shreyas Satish on Stack Overflow See other posts from Stack Overflow or by Shreyas Satish
Published on 2010-04-05T17:07:55Z Indexed on 2010/04/05 17:13 UTC
Read the original article Hit count: 343

Filed under:
|
|

Lets say I have an array : a=[[1,2,3],[4,5]] and I have another array : b=[[2.5,1.5,3.5],[1.5,2.5]]

I need to sort 'a' with respect to 'b'. i.e the output should be = [[3,1,2],[5,4]]

I tried but my code seemed to be very lengthy. It would be great if you could help me out.Thanks!

© Stack Overflow or respective owner

Related posts about ruby

Related posts about array