Liberty BASIC Community Forum
« Bubble Sort »

Welcome Guest. Please Login or Register.
Nov 17th, 2017, 1:25pm


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Bubble Sort  (Read 240 times)
alincon2001
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 494
xx Bubble Sort
« Thread started on: Oct 23rd, 2016, 10:40am »

The LB sort command is good for almost all cases, but in this case, I needed to sort some print lines on a field in the middle of the line, so I used the bubble sort.
It compares pairs of lines and flips them if the second one is lower than the first one.

r.m.

Code:
    FOR i=1 TO chosenCtr                       'sort to time sequence
      FOR j=1 TO (chosenCtr-1)                    		
        IF mid$(classChosen$(j),17,4) > mid$(classChosen$(j+1),17,4) THEN
		  temp$ = classChosen$(j)  
		  classChosen$(j)=classChosen$(j+1)
		  classChosen$(j+1)=temp$
	END IF
      NEXT j
    NEXT i   
 
User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5560
xx Re: Bubble Sort
« Reply #1 on: Oct 23rd, 2016, 12:18pm »

We lose a massive amount of hints and tips lost in the mists of time. Bubble Sorts are slow, if you have a large amount of data to sort manually then review this Quick Sort tutorial.

http://jbfilesarchive.com/phpBB3/download/file.php?id=41
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls