Well the title of your question says you want to sort the vector. But the code posted prints the pairs and sums the odd marks. Following is an answer to what was asked, ordering a vector of int. If you want to put only the odd marks in ascending order, follow the logic of separating them and put them in a list then use this Array.Sort(numeros);
to order.
int[] numeros = { 10, 5, 20, 60, 1, 5, 8, 30, 11, 20, 25, 30, 50 };
Console.Write("Números ordenados");
Array.Sort(numeros);
// Escrevendo array
foreach (int i in numeros) Console.Write(i + " ");
By following your code, to order only the impairments would look like this:
int c = 0;
List numeros = new List(){ 10, 5, 20, 60, 1, 5, 8, 30, 11, 20, 25, 30, 50 };
List impares = new List();
Console.Write("Números pares");
foreach (int num in numeros)
{
if (num % 2 == 0)
{
Console.Write(num + ", ");
}
else
{
impares.Add(num);
}
}
Array.Sort(impares);
Console.WriteLine("\n numeros impares ordenados");
foreach (int ordImp in impares)
{
System.Console.WriteLine(ordImp);
}
Console.ReadKey();