1. sort_column() Error
- Posted by euphoric (admin) Jul 07, 2010
- 1216 views
sort_column() can sort by column 1, but it can't seem to sort by column 2... Can anybody figure out why?
include std/sort.e include std/console.e sequence s = "", letters = "abcdefghijklmnopqrstuvwxyz" integer rc, rn, SORTER = 1, SHOW = 7 for t=1 to 1000 do rc = rand(length(letters)) rn = rand(10000) s = append(s,{ letters[rc], rn }) end for while wait_key() != 27 entry do if SORTER = 1 then SORTER = 2 else SORTER = 1 end if entry s = sort_columns( s, {SORTER} ) printf(1,"\n\nSort by Column %d\n\n",{SORTER}) for t=1 to SHOW do puts(1,"\t" & s[t][1] & "\t") ?s[t][2] end for end while
2. Re: sort_column() Error
- Posted by DerekParnell (admin) Jul 07, 2010
- 1090 views
sort_column() can sort by column 1, but it can't seem to sort by column 2... Can anybody figure out why?
Your code is fine. The problem was in the standard library code. The sort_columns() routine was converting the column data to uppercase before comparing it - but uppercase conversion doesn't work for data which isn't ASCII text - such as in your example.
I've uploaded a fix to the SVN repository.
3. Re: sort_column() Error
- Posted by euphoric (admin) Jul 07, 2010
- 1081 views
sort_column() can sort by column 1, but it can't seem to sort by column 2... Can anybody figure out why?
The problem was in the standard library code...
I've uploaded a fix to the SVN repository.
A ha! Thanks Derek. :)
5. Re: sort_column() Error
- Posted by euphoric (admin) Jul 08, 2010
- 1031 views
Did you try sortok()?
No, I'm sticking with the standard library for this job. :)