QB / QB64 Discussion Forum      Other Subforums, Links and Downloads

 Return to Index  

Extemely Simple and Intuitive Sort

January 31 2008 at 3:52 PM
qbguy  (no login)

Response to Shell Sort, Bubble Sort, Sorting in general


Look at how simple and elegant this sort is:

* If the value at the end is smaller than the value at the start, swap them.
* If there are 3 or more elements in the current list subset, then:
    o Sort the initial 2/3 of the list (recursively)
o Sort the final 2/3 of the list (recursively)
o Sort the initial 2/3 of the list again (recursively)
o else: exit the procedure

Very simple, can be accomplished with very little code.


  IF A(I)>A(J) SWAP A(I), A(J)


 Respond to this message   
 Copyright © 1999-2018 Network54. All rights reserved.   Terms of Use   Privacy Statement  

Newbies usually go to www.qbasic.com and click on The QBasic Forum
Forum regulars have their own ways, which include The QBasic Community Forums