Last active
June 14, 2019 13:39
-
-
Save deepumi/53a8476f30cf3f19e8981b22922314d0 to your computer and use it in GitHub Desktop.
Insertion Sort
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
string[] arr = { "orange", "nest", "apple", "ABC","xyz", "bana", "cat"}; | |
for (int i = 0; i < arr.Length; i++) | |
{ | |
for (int j = i + 1; j < arr.Length; j++) | |
{ | |
if (arr[i]?.CompareTo(arr[j]) > 0) | |
{ | |
var temp = arr[j]; | |
arr[j] = arr[i]; | |
arr[i] = temp; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment