I need to sort QHash.

In java (HashMap) (code below) works correctly.

Someone can please help me translate this Java code to Qt?

Main.java
Qt Code:
  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3. import java.util.HashMap;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. HashMap<String ,Word> h = new HashMap<String, Word>();
  8.  
  9. popHash(h); // I have a hash and want to order it by the value of each key.
  10.  
  11. ArrayList<Word> aux = new ArrayList<Word>(); // QList<Word> list;
  12.  
  13. for(String s:h.keySet()){
  14. aux.add(h.get(s));
  15. }
  16.  
  17. Collections.sort(aux); // qsort(list);
  18.  
  19. for(Word p:aux){
  20. System.out.println(p);
  21. }
  22. }
  23.  
  24. private static void popHash(HashMap<String, Word> h) {
  25. String[] word = {"not", "using", "Qt", "but", "in", "Hash", "Java", "know", "sort", "I"};
  26. int[] cont = {2, 5, 0, 3, 1, 6, 4, 8, 7, 9};
  27. Word p;
  28.  
  29. for(int i=0; i<cont.length; i++){
  30. p = new Word();
  31. p.setWord(word[i]);
  32. p.setCount(cont[i]);
  33. h.put(p.getWord(), p);
  34. }
  35. }
  36. }
To copy to clipboard, switch view to plain text mode 

/* Output:
9 I
8 know
7 sort
6 Hash
5 using
4 Java
3 but
2 not
1 in
0 Qt
*/


Word.java
Qt Code:
  1. public class Word implements Comparable<Word> {
  2. private String word;
  3. private int count;
  4.  
  5. public String getWord() {
  6. return word;
  7. }
  8.  
  9. public void setWord(String word) {
  10. this.word = word;
  11. }
  12.  
  13. public int getCount() {
  14. return count;
  15. }
  16.  
  17. public void setCount(int count) {
  18. this.count = count;
  19. }
  20.  
  21. // How do I do this comparison function in Qt? - operator <(Word &p) not working
  22. @Override
  23. public int compareTo(Word o) {
  24. return o.count - this.count;
  25. }
  26. @Override
  27. public String toString(){
  28. return this.count +" "+this.word;
  29. }
  30. }
To copy to clipboard, switch view to plain text mode 

Thank you very much.