December 03, 2020, 08:48:47 PM

Author Topic: [bb] Alphabetical Sort by mrtricks [ 1+ years ago ]  (Read 526 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Alphabetical Sort by mrtricks [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Alphabetical Sort
Author : mrtricks
Posted : 1+ years ago

Description : Uses types so you can have as many strings as you want. Converts to all lower case. Type in as many strings as you want, then hit return with an empty string and it will sort them all for you.

Code :
Code: BlitzBasic
  1. ;ALPHABETICAL SORT BY ROBIN KING 5/1/2002
  2. ;
  3. ;type in as many phrases/words as you like, then hit return with an empty input to sort them all
  4.  
  5.  
  6. Type sort
  7.         Field name$
  8. End Type
  9.  
  10. ;INPUT SOME TEXTS
  11. Repeat
  12.         in$=Input()
  13.         If in$<>""
  14.                 s.sort=New sort
  15.                 s
  16. ame$=Lower$(in$)
  17.         EndIf
  18. Until in$=""
  19.  
  20. ;PRINT THEM IN THE ORDER YOU TYPED THEM
  21. Print
  22. For s.sort=Each sort
  23. Print s
  24. ame$
  25. Next
  26. Print
  27. Print
  28.  
  29.  
  30.  
  31.  
  32.  
  33. ;SORT
  34.  
  35. s.sort=First sort
  36. Repeat
  37.         If s=Null Then Exit
  38.         a$=s
  39. ame$
  40.         s.sort=After s
  41.         If s=Null Then Exit
  42.         b$=s
  43. ame$
  44.         If a$>b$
  45.                 Insert s Before Before s
  46.                 If s.sort<>First sort Then s=Before s
  47.         EndIf
  48. Forever        
  49.  
  50.  
  51.  
  52.  
  53.  
  54. ;PRINT THEM IN SORTED ORDER
  55. For s.sort=Each sort
  56. Print s
  57. ame$
  58. Next
  59.  
  60. Repeat
  61. Until KeyDown(1)
  62. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal