(Comp.sys.hp48) Item: 1416 by jsw@well.sf.ca.us [James Weisbin] Subj: Sortr library for G & S series Date: 02 Aug 1993 --> S/SX/G/GX Some time ago, Joe Horn posted his SORTLS, version 1.0. In that posting, he writes: > Sorting is case sensitive, for speed optimization. Also for speed, > the list elements are not type checked, which shouldn't cause any > problems, but don't expect meaningful sorting of non-string elements. Here is a modified version of his sort routine, which will sort lists containing any objects, including lists of lists..., into strict alpha- betical order (non-case sensitive). [Warning: this means that numbers are treated as words, and alphabetized; thus { 1 4 22 55 333 666 } is in numerical order, but this library "alphabetizes" them as { 1 22 333 4 55 666 }. This is ideal for product numbers, but not for actual numerical values. Use SORTLN on Goodies Disk #8 for that. -jkh-] The routine "rcar" (recursive CAR) recurses until it gets the first non-list element in a list. UPcase, by author unknown to me (my apologies) is an ML routine which turns a string to uppercase characters. [Several people wrote upper-case programs; the one on Goodies Disk #2 is by Brian Maguire. -jkh-] GX users note: You have a SORT command built in, but it is case-sensitive, therefore you still might find this one useful. Instructions: Install the library "sortr", lib number is 1765, which is the same number as ROLDX. (ROLDX users note: if you have ROLDX, you already have these routines and can use sortR from the main Roldx menu). Put a list on the stack and execute "sortr". Try doing this with your Vars list - it's great for sorting a directory into alpha-order. The "unsuported" entry point, #142A6 compares two strings and returns 1 if level two is less than level one, 0 if not. It is a valid entry as of revision R (GX). Thanks and kudos to Joe Horn for all his great work.