This is simple code in C (selection sort):

```
#include <stdio.h>
#include <stdlib.h>
#define ItemCount 10

int numbers[ItemCount] = {4,9,3,7,2,5,10,2,12,6};    

int MinNumberIndex(int start) {
    int i;
    int minindex = start;

    for (i = start + 1; i < ItemCount; i++)
        if (numbers[minindex] > numbers[i])
            minindex = i;

    return minindex;    
}

void SelectionSort() {
    int i,temp,minindex;

    for (i = 0; i < 10; i++) {
        minindex = MinNumberIndex(i);

        temp = numbers[i];
        numbers[i] = numbers[minindex ];
        numbers[minindex ] = temp;                                                                          
    }
}

int main() {
    int i;

    SelectionSort();
    for (i = 0; i < 10; i++)
        printf("%d\t",  numbers[i]);

    system("pause");    
}

```

And it is working ok... but if I change a little bit like this(in selectionSort function):

```
for (i = 0; i < 10; i++) {
    temp = numbers[i];
    numbers[i] = numbers[MinNumberIndex(i)];
    numbers[MinNumberIndex(i)] = temp;                                                                          
}

```

it is not working... Why? It seems to be the same.