Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'sort ELEMENTS of an array, descending (bubble-sort)
- ' call: A(n)= array, F= 1st position, L= last position, D= descending order, S= string sort
- ' exit: A(n)= sorted, descending, positions F thru L
- ' temp: I= Incr, J= Incr, swapped%
- <bubbleSort> '
- for I = F to L - 1
- swapped% = 0
- for J = F to L - I - 1
- if S = 1 and uaRowsSort$(J + D) > uaRowsSort$(J + (D = 0)) then gosub <bubbleSortSwap>
- if S = 0 and val(uaRowsSort$(J + D)) > val(uaRowsSort$(J + (D = 0))) then gosub <bubbleSortSwap>
- next J
- if swapped% = 0 then J = L - I - 1
- next I
- return
- <>
- <bubbleSortSwap> '
- 'swapTmp% = uaRowsSort%(J)
- 'uaRowsSort%(J) = uaRowsSort%(J + 1)
- 'uaRowsSort%(J + 1) = swapTmp%
- swapTmp$ = uaRowsSort$(J)
- uaRowsSort$(J) = uaRowsSort$(J + 1)
- uaRowsSort$(J + 1) = swapTmp$
- swapTmp$ = uaRows$(J)
- uaRows$(J) = uaRows$(J + 1)
- uaRows$(J + 1) = swapTmp$
- swapped% = 1
- return
- <>
- F = edmDone% + 1 : L = dmLnLen% + edmDone% : D = (uaSortAsc% = 0) : S = 1
- gosub <bubbleSort>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement