题解 | #排序#
排序
https://www.nowcoder.com/practice/2baf799ea0594abd974d37139de27896
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 将给定数组排序 * @param arr int整型一维数组 待排序的数组 * @return int整型一维数组 */ public List<int> MySort (List<int> arr) { // write code here int temp=0; for(int i=1;i<arr.Count;i++){ for(int j=0;j<i;j++){ if(arr[i]<arr[j]){ temp=arr[i]; for(int k=i;k>j;k--){ arr[k]=arr[k-1]; } arr[j]=temp; } } } return arr; } }