Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc bubble_sort( arr: var openarray[ int ] ) =
- for i in low( arr ) .. high( arr ):
- for j in i .. high( arr ) - i - 1:
- if arr[ j ] > arr[ j + 1 ]:
- swap arr[ j ], arr[ j + 1 ]
- var arr = @[ 5, 6, 2, 1, 3 ]
- bubble_sort( arr )
- echo repr( arr )
Add Comment
Please, Sign In to add comment