1 void selectSort(LineList R[], int n) 2 { 3 int i, j, index; 4 for (i = 1; i < n; i++) 5 { 6 index = i; 7 for (j = i + 1; j <= n; j++) 8 { 9 if (R[j].key < R[index].key) 10 { 11 index = j; 12 } 13 } 14 15 if (index != i) 16 { 17 R[0].key = R[i].key; 18 R[i].key = R[index].key; 19 R[index].key = R[0].key; 20 } 21 } 22 }