Skip to content

Instantly share code, notes, and snippets.

@paulohenriquesn
Created October 4, 2018 07:32
Show Gist options
  • Save paulohenriquesn/1dab20e2d21f130e8d04cabcab702937 to your computer and use it in GitHub Desktop.
Save paulohenriquesn/1dab20e2d21f130e8d04cabcab702937 to your computer and use it in GitHub Desktop.
static List<int> SortArray(int[] array)
{
int[] result = new int[array.Length];
List<int> memory = new List<int>();
List<int> toResult = new List<int>();
foreach (var x in array)
{
memory.Add(x);
}
check:
for (int i = 0; i < memory.Count(); i++)
{
toResult.Add(memory.Min());
memory.RemoveAt(memory.IndexOf(memory.Min()));
}
if (memory.Count() != 0)
{
goto check;
}
return toResult;
}
@paulohenriquesn
Copy link
Author

  int[] ar = new int[] { 10, 25, 1, 2, 3, 9, 35 };

        Console.WriteLine(SortArray(ar)[2]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment