for int int arrayToSort count i-- Figure tempFigure1 Figure arrayToSor

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
for (int i = (int)([arrayToSort count] - 1); i >= 0; i--) {
Figure* tempFigure1 = ((Figure*)arrayToSort[i]);
for (int c = i-1; c >= 0; c--){
Figure* tempFigure2 = ((Figure*)arrayToSort[c]);
Figure* biggerFigure = compareFigures(tempFigure1, tempFigure2);
if (biggerFigure != tempFigure2){
arrayToSort[c] = biggerFigure;
arrayToSort[i] = tempFigure2;
}
}
}
До сортировки:
2014-12-13 22:41:35.623 lesson4hw[7662:756123] Square of 0 figure is 772.83
2014-12-13 22:41:35.623 lesson4hw[7662:756123] Square of 1 figure is 75.00
2014-12-13 22:41:35.623 lesson4hw[7662:756123] Square of 2 figure is 50.27
2014-12-13 22:41:35.623 lesson4hw[7662:756123] Square of 3 figure is 9.00
2014-12-13 22:41:35.624 lesson4hw[7662:756123] Square of 4 figure is 98.00
2014-12-13 22:41:35.624 lesson4hw[7662:756123] Square of 5 figure is 0.00
2014-12-13 22:41:35.624 lesson4hw[7662:756123] Square of 6 figure is 314.16
2014-12-13 22:41:35.624 lesson4hw[7662:756123] Square of 7 figure is 650.31
2014-12-13 22:41:35.624 lesson4hw[7662:756123] Square of 8 figure is 9.00
2014-12-13 22:41:35.624 lesson4hw[7662:756123] Square of 9 figure is 2.00
После:
2014-12-13 22:41:35.625 lesson4hw[7662:756123] Square of 0 figure is 772.83
2014-12-13 22:41:35.625 lesson4hw[7662:756123] Square of 1 figure is 650.31
2014-12-13 22:41:35.625 lesson4hw[7662:756123] Square of 2 figure is 650.31
2014-12-13 22:41:35.625 lesson4hw[7662:756123] Square of 3 figure is 650.31
2014-12-13 22:41:35.625 lesson4hw[7662:756123] Square of 4 figure is 650.31
2014-12-13 22:41:35.625 lesson4hw[7662:756123] Square of 5 figure is 650.31
2014-12-13 22:41:35.626 lesson4hw[7662:756123] Square of 6 figure is 650.31
2014-12-13 22:41:35.626 lesson4hw[7662:756123] Square of 7 figure is 75.00
2014-12-13 22:41:35.626 lesson4hw[7662:756123] Square of 8 figure is 9.00
2014-12-13 22:41:35.626 lesson4hw[7662:756123] Square of 9 figure is 0.00