×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Sort Lotto numbers

 Forum Search FAQs Links MVPs

## Sort Lotto numbers

(OP)
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.

### RE: Sort Lotto numbers

(OP)
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

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

#### Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!