Last active
December 7, 2015 06:02
-
-
Save hr1383/182c78fe963605778b19 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
change this | |
for (count; count < arraySize-1; count++) { | |
for (secondCounter = count + 1; secondCounter < arraySize; secondCounter++) { | |
if (rec[count].salary > rec[secondCounter].salary) { | |
temp = rec[count].salary; | |
rec[count].salary = rec[secondCounter].salary; | |
rec[secondCounter].salary = temp; | |
} | |
} | |
} | |
to | |
// you need to swap the entire record | |
for (count; count < arraySize-1; count++) { | |
for (secondCounter = count + 1; secondCounter < arraySize; secondCounter++) { | |
if (rec[count].salary > rec[secondCounter].salary) { | |
temp = rec[count]; | |
rec[count] = rec[secondCounter]; | |
rec[secondCounter] = temp; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment