for (int i = 0; i < array.Length; i++) { for (int j = i; j < array.Length; j++) { if (Convert.ToInt32(array[i]) > Convert.ToInt32(array[j])) { var temp = array[i]; array[i] = array[j]; array[j] = temp; } } }