Skip to content

Instantly share code, notes, and snippets.

@yemaw
Created February 13, 2013 03:52
Show Gist options
  • Save yemaw/4942116 to your computer and use it in GitHub Desktop.
Save yemaw/4942116 to your computer and use it in GitHub Desktop.
Manually Sort Integer Array
using System;
class ManualIntegerArraySorting
{
public static void Main() {
int[] arr = new int[10]{5,3,9,5,4,1,3,56,234,1};
int smallest, pointer, tmp;
for(int i=0; i<10; i++){
}
for (int index = 0; index < 10; index++) {
smallest = arr[index];
pointer = index+1;
while(pointer<10){
if(smallest > arr[pointer]){
tmp = smallest;
smallest = arr[pointer];
arr[pointer] = tmp;
}
pointer++;
}
arr[index] = smallest;
}
for (int k = 0; k < 10; k++) {
Console.WriteLine(arr[k]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment