Fast ESF Sort 0.70 Beta
-----------------------

=> By Jol Bourquard (NumLOCK) from XLR8 Tech ! <=

Mail: numlock79@hotmail.com -- I speak French too
Web : http://fly.to/numlock -- no HP stuff, but 3D Java demo

---------------------------------------------------------------------
Disclaimer: I (the author) am NOT responsible for whatever
            this program might cause to you or your calculator !

            This program is freeware, but you are not allowed
            to reverse-engineer it.  You may distribute it to
            anyone, as long as it's not modified of course.
            Please, also include this text file along with the binary.

Warning:    This program is pure Assembly code, and it's
            bypassing most standard rom routines. If there's
            a bug in my memory management routines, it's likely to
            clear your RAM ! Beware and backup your memory !!
---------------------------------------------------------------------

This program takes a list of strings, and uses the Fast_ESF sorting algorithm to sort it.
Please e-mail me if you want to include my binary in your programs.

I've created the ESF algorithm, to be faster than a Quicksort in many cases. I'd say Quicksort is a 2nd order sort, and ESF is Kth order (K being a big natural, power of 2). It's harder to implement, and its performance relies on the nature of input data, but doesn't really care about the input data being already sorted or not.

Stack  : {S1 S2 S3 ... Sn}  =>  Sorted list (S1..Sn = N strings of any length)
Target : HP49, and probably HP48g(x) -- not tested
Type   : 100% ASM, Code object
Size   : 942.5 bytes
Limits : The biggest sortable list depends on free RAM
Safety : Full argument checking -- Agressive but safe(?) memory management

Performance ('N' random 5-byte strings, almost 256k Free, LCD ON, after MEM DROP) :

N     Hp49_SORT  ESF 0.52  ESF 0.70  Speed_Factor
16     658 ms     113 ms   109 ms    x 6.04
32     1.22 s     149 ms   129 ms    x 9.46
64     2.61 s     210 ms   170 ms    x 15.4
128    5.87 s     374 ms   252 ms    x 23.3
256    14.6 s     799 ms   422 ms    x 34.6
512    38.7 s     1.63 s   781 ms    x 49.6
1024   104  s     2.86 s   1.63 s    x 63.8
2048   287  s     4.69 s   3.76 s    x 76.3
4096   841  s     8.60 s   7.63 s    x 110
8192  unknown     18.7 s   13.8 s    > 250

Of course, the outputs of SORT and ESF were exactly the same.
Please note I only took powers of 2 and fixed-length strings for convenience only. Hopefully there's no such restriction.

What's new ? (!! = important)
-----------------------------
0.52 -> 0.70 : - !! Aggressive structural optimization: now 4% to 108% faster !
               - !! Now bullet-proof for most worst cases (like N^2 behaviour).
               - !! Much lower memory requirements
               - MANY code cleanups (but no bugfixes)
               - The code is becoming quite complex :-p
               - Benchmarked everything again ...

Please report me ANY bugs or worst-case scenarios ! Thanks.
Have a lot of Fun !!!

Other hp49 programs from me are:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Metallurgic Animator, a ML animation program (takes a list of 131x64 GROBs)
  It also allows for 4-color images display (and more..)  on http://www.hpcalc.org

- Terminaltor: Connect your hp49 to a Linux box !! (also on hpcalc.org)
