Page 1 of 1

[04 Dec 2008] Sort and locale

Posted: Sat Jun 13, 2020 5:32 pm
by lazi
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 04 Dec 2008 00:54:21 +0100

Hello Andreas!

The story started when I wanted to play an animation while sorting a large text table.

I made a quicksort function and the result shocked me.

The same table which takes 4913 ms to sort by the Sort() function takes ~0 ms (zero) by the quicksort algorithm.

I know that optimization is behind functionality, but what could cause such a huge difference?

The problem is with all of the sort methods that I cannot sort accented characters correctly. It would be great to have a function that use locale.library/StrnCmp (on the Amiga, and whatever function on other systems) then I could use it in my quicksort function.

The second problem is that I couldn't figured out how can I pass a table to a function. I'd like to make a p_qsort(table,first,last) function to be useable generally. Currently I had to hardwire the table name in the function.

And one last question: Should I reserve from the Christmas money for a soon to be released new Hollywood upgrade? :-)

[04 Dec 2008] Re: Sort and locale

Posted: Sat Jun 13, 2020 5:32 pm
by lazi
Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 04 Dec 2008 01:05:21 +0100

Hi!

It is a fast correction! Don't get serious the following in my last post because it is too late and something slipped out of my control :)

[05 Dec 2008] Re: Sort and locale

Posted: Sat Jun 13, 2020 5:32 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 05 Dec 2008 23:30:04 +0100
Hello Andreas!

The story started when I wanted to play an animation while sorting a large text table.

I made a quicksort function and the result shocked me.

The same table which takes 4913 ms to sort by the Sort() function takes ~0 ms (zero) by the quicksort algorithm.

I know that optimization is behind functionality, but what could cause such a huge difference?
Bubble sort :-)
The problem is with all of the sort methods that I cannot sort accented characters correctly. It would be great to have a function that use locale.library/StrnCmp (on the Amiga, and whatever function on other systems) then I could use it in my quicksort function.
Yes, this is planned.
The second problem is that I couldn't figured out how can I pass a table to a function. I'd like to make a p_qsort(table,first,last) function to be useable generally. Currently I had to hardwire the table name in the function.
Hmm, you can pass tables to functions just as normal arguments e.g.

Code: Select all

Function p_TestFunc(t)
   DebugPrint(t[0], t[1])
EndFunction

p_TestFunc({16, 82})   ; prints 16 82
And one last question: Should I reserve from the Christmas money for a soon to be released new Hollywood upgrade? :-)
I won't probably make it before Christmas but we're getting closer :)