选择排序,小能手
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
* 将给定数组排序
* @param arr int整型vector 待排序的数组
* @return int整型vector
*/
vector<int> MySort(vector<int>& arr) {
// write code here
int start =0;
int end = arr.size();
while(start<end) {
int i = start;
for(int j=i+1;j<end;j++) {
if(arr[i]>arr[j]){
i = j;
}
}
int temp = arr[i];
arr[i] = arr[start];
arr[start] = temp;
start++;
}
return arr;
}
};