Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!willett!ForthNet From: ForthNet@willett.UUCP (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: All Sorts of Sorts Message-ID: <504.UUL1.3#5129@willett.UUCP> Date: 18 Feb 90 23:42:15 GMT Organization: Latest link in the ForthNet chain. (Pgh, PA) Lines: 26 Date: 02-17-90 (13:52) Number: 2918 (Echo) To: IAN GREEN Refer#: 2881 From: DON MADSON Read: NO Subj: LEARN TO SORT Status: PUBLIC MESSAGE Except for a list that's already sorted the selection sort performs better than the bubble sort. The bubble sort (with a flag) only performs well on an ordered list. If the list is already ordered why sort it? When a new record is added insert it where it belongs and the list is still sorted. If a record is deleted close the gap. I suppose one option is to include every possible sort in your program and before sorting your database perform an analysis of that data to determine which sorting procedure to call. Or ... just include one that performs well most of the time. There is a good chapter on sorting in Wirth's book "Algorithms + Data Structures = Programs." --- ~ EZ-Reader 1.14 ~ ><><><><><><><><><><><><><><<>><><> ----- This message came from GEnie via willett through a semi-automated process. Report problems to: 'uunet!willett!dwp' or 'willett!dwp@gateway.sei.cmu.edu'