Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Lotto numbers

Status
Not open for further replies.

TinLegs

Programmer
Jan 14, 2003
100
NZ
Does anyone have a function that will sort 6 Lotto numbers low to high.

Example: From this 21 32 36 01 38 05 to this 01 05 21 32 36 38

I recall a function in BASIC which done this, it included the SWAP command which Clarion 6.1 does not have and I can not seem to find an alternative in Clarion?

Guess what I am looking for is a Clarion 'Bubble Sort'?

Thank you fellow Clarion users.
 
If its of any help to others I have found a solution (code below).
Sure the code is very basic but it works and could be a basis to improve on.
---------------- Code ------------------
SortPIC Routine !For 6 Lotto numbers

LOC:SortToDo=TRUE
LOC:Temp = 0

LOOP

IF LottoNumber[1] > LottoNumber[2]
LOC:SortToDo = TRUE
LOC:Temp = LottoNumber[2]
LottoNumber[2] = LottoNumber[1]
LottoNumber[1] = LOC:Temp
END

IF LottoNumber[2] > LottoNumber[3]
LOC:SortToDo = TRUE
LOC:Temp = LottoNumber[3]
LottoNumber[3] = LottoNumber[2]
LottoNumber[2] = LOC:Temp
END

IF LottoNumber[3] > LottoNumber[4]
LOC:SortToDo = TRUE
LOC:Temp = LottoNumber[4]
LottoNumber[4] = LottoNumber[3]
LottoNumber[3] = LOC:Temp
END

IF LottoNumber[4] > LottoNumber[5]
LOC:SortToDo = TRUE
LOC:Temp = LottoNumber[5]
LottoNumber[5] = LottoNumber[4]
LottoNumber[4] = LOC:Temp
END

IF LottoNumber[5] > LottoNumber[6]
LOC:SortToDo = TRUE
LOC:Temp = LottoNumber[6]
LottoNumber[6] = LottoNumber[5]
LottoNumber[5] = LOC:Temp
END

IF LottoNumber[1] < LottoNumber[2] AND LottoNumber[2] < LottoNumber[3] AND LottoNumber[3] < LottoNumber[4] |
AND LottoNumber[4] < LottoNumber[5] AND LottoNumber[5] < LottoNumber[6] THEN LOC:SortToDo=FALSE.

IF LOC:SortToDo=FALSE THEN BREAK.

END !LOOP

DO RefreshWindow
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top