1. sort_column() Error

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 
new topic     » topic index » view message » categorize

2. Re: sort_column() Error

euphoric said...

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.

new topic     » goto parent     » topic index » view message » categorize

3. Re: sort_column() Error

DerekParnell said...
euphoric said...

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. :)

new topic     » goto parent     » topic index » view message » categorize

4. Re: sort_column() Error

Did you try sortok()?

useless

new topic     » goto parent     » topic index » view message » categorize

5. Re: sort_column() Error

useless said...

Did you try sortok()?

No, I'm sticking with the standard library for this job. :)

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu