public sortNode[] sort() { boolean flag = true; for (int i = 0, len = arr.length-1; i < len; i++) { for (int j = 0; j < len - i - 1; j++) { if (((sortNode)arr[j]).getIndex() > ((sortNode)arr[j + 1]).getIndex()) { sortNode temp = (sortNode)arr[j + 1]; arr[j + 1] = arr[j]; arr[j] = (T) temp; flag = false; } } if(flag)break; } return (sortNode[]) arr; }
标签:getIndex,arr,Java,len,sortNode,flag,冒泡 From: https://www.cnblogs.com/laremehpe/p/16915955.html