Created
May 6, 2011 09:56
-
-
Save sdarlington/958711 to your computer and use it in GitHub Desktop.
Bubblesort implementation for Sybase Aleri (SPLASH)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int32 bubble_sort_double (vector(double) data) { | |
int32 v_len := size(data); | |
int32 v_outer := 0; | |
while (v_outer < v_len) { | |
int32 v_curr := 1; | |
while (v_curr < v_len - v_outer) { | |
if (data[v_curr - 1] > data[v_curr]) { | |
swap_double (data, v_curr, v_curr - 1); | |
} | |
v_curr++; | |
} | |
v_outer++; | |
} | |
} | |
int32 swap_double (vector(double) data, int32 el1, int32 el2) { | |
double temp := data[el1]; | |
data[el1] := data[el2]; | |
data[el2] := temp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment