ruby sortby 3rd element in a multidimential array npot working properly
Posted
by Steven
on Stack Overflow
See other posts from Stack Overflow
or by Steven
Published on 2010-05-19T16:59:43Z
Indexed on
2010/05/19
17:10 UTC
Read the original article
Hit count: 147
Hi,
I'm using ruby to sort an array where each element in the array is another array.
I have this:
Data = Data.SortBy { |Info| info[3] }
example data in this column:
3.1
2
5.65
-1
0.4
-9.43
-10.87
-2.3
It should sort this into:
5.65
3.1
2
0.4
-1
-2.3
-9.43
-10.87
But it comes out like this:
5.65
3.1
2
0.4
-1
-10.87
-2.3
-9.43
It's only comparing the first char of the float... not the whole number?
© Stack Overflow or respective owner