个人看法: 先定义出book对象,sort algorithm对象(应该是个decorator,就是可以pipeline到另 外一个alg对象上),然后需要定义less than, 定义adapter到STL quicksort。 public void sort() { call adaptoer method or obj from i to n. for (i = k; i< booklist.count; i++) { if key[i] = key [j] continue; else if (mydecotor is not null) mydecortor.setvalue(j, k); mydecortor.sort(); } 大概框架应该是这样。
可以把Books放到一个Array吗? 然后 Arrays.Sort(bookArray, new BookCompare()) 事先定义一个Class BookCompare implements Comparator { //Override the compareTo method public int compareTo(Book book1, Book book2) { //rating first //if a tie, based on price } }