实现用于多密钥排序的伪代码

时间:2014-11-14 03:03:26

标签: java sorting arraylist queue

这个想法是对一个对象列表进行排序,每个对象都包含两个键值。

这样的算法的伪代码就像我这样给了我:

To sort a list of objects with more than one key do
    for each key position P, Least significant to most significant key do
        Establish one queue for each of the key values
        For each object O in the list, do 
            place O in the queue corresponding to the key or O in position P
        end
   end 
end

我不知道这是如何转换为代码的,我甚至很难理解伪代码。 但是让我说我​​有这个:

class main(){
sorter.build();
sorter.sort();
}


class sorter(){
public static ArrayList<lyrics> deck = new ArrayList<>();

public void build(){
//add.card objects to ArrayList deck
}

public void sort(){
// how do I begin the sort?
}


class card(){
public String suite;
public String rank;
public card(String s, String r){
suite = s;
rank = r;
}

0 个答案:

没有答案