📄 sort.java
字号:
package myutilities;
public class Sort {
/* The Sort class by J M Bishop Feb 1997
* revised October 1997
* Provides one sorting method
* for arrays of objects of any length.
* where the objects' class implements the
* Sortable interface.
*/
public static void selectionSort(Sortable a [], int n) {
Sortable temp;
int chosen;
for (int leftmost = 0; leftmost < n-1; leftmost++) {
chosen = leftmost;
for (int j = leftmost+1; j < n; j++) {
if (a[j].lessThan(a[chosen])) {
chosen = j;
}
}
temp = a[chosen];
a[chosen] = a[leftmost];
a[leftmost] = temp;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -