Ooops
October 28, 2020, 11:35:56 PM

Author Topic: [bb] BubbleSort by skidracer [ 1+ years ago ]  (Read 1809 times)

Offline BlitzBot

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

Description : sorts blitz object collections

Code :
Code: BlitzBasic
  1. ; sort.bb
  2.  
  3. Type bob
  4.     Field    z
  5. End Type
  6.  
  7. Function SortBobs()
  8.     b.bob=First bob
  9.     flag=True
  10.     While flag
  11.         flag=False
  12.         bb.bob=Last bob
  13.         While bb<>b
  14.             bbb.bob=Before bb
  15.             If bbb=Null Exit
  16.             If bbz<bbbz
  17.                 Insert bbb After bb
  18.                 flag=True
  19.             Else
  20.                 bb=bbb
  21.             EndIf
  22.         Wend
  23.         b=After bb
  24.     Wend
  25. End Function
  26.  
  27. For i=1 To 100
  28.     b.bob=New bob
  29.     bz=Rnd(1000)
  30. Next
  31.  
  32. SortBobs
  33.  
  34. For b.bob=Each bob
  35.     DebugLog bz
  36. Next
  37.  
  38. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal