Path: utzoo!utgpu!water!watmath!clyde!rutgers!sdcsvax!ucbvax!ARIZONA.EDU!kwalker From: kwalker@ARIZONA.EDU ("Kenneth Walker") Newsgroups: comp.lang.icon Subject: Re: complicated sorting Message-ID: <8801032038.AA13538@megaron.arizona.edu> Date: 3 Jan 88 20:38:47 GMT References: <397@grand.UUCP> Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The ARPA Internet Lines: 29 Date: 1 Jan 88 05:33:51 GMT From: grand!day@uunet.uu.net (Dave Yost) I need to sort a list of records according to complicated sort criteria, The standard icon sort() routine is not making this task easy. What I need is something more like the C library qsort routine that lets me provide my own comparison routine. Is there any hope of my finding something like this in icon, or am I missing some elegant way to do this with the existing sort() routine? The comparison routine used by the Icon sort function is built into the run-time system and cannot be overriden without modifying Icon. Sometimes a comlicated sort criterion can be handled by constructing artifical keys for records such that a key sorts the corrosponding record where it needs to go in the sequence. The records can then be put in a table using the keys and the table can be sorted to produce the desired sequence of records. The artifical keys would typically be strings. If such keys are not easy to produce, your best bet is probably to write a sort procedure in Icon specific to your application.