Hello!

I want to sort a list containing QDates. After trying two ways, I could not overcome the probem. Could anyone help?
Here are my codes:

First, I used the function: qSort() as folowed:

Qt Code:
  1. qSort(list.benin(), list.end())
To copy to clipboard, switch view to plain text mode 

Form this code, the output is a list in which only day names are sorted. For example, if I have Mo (for monday), Fr (for friday) and Sat (for saturday), the output order is: Fr 22 2014, Mo 12 2014 and Sat 25 2014.

Second, with the following code, nothing is solved, the order for the imput is the same for the output.

Qt Code:
  1. for(int g = 0; g<list.size()-1; g++)
  2. {
  3. Date1 = list[g];
  4.  
  5. for(int l = g+1; l<list.size(); l++)
  6. {
  7. Date2 = list[l];
  8.  
  9. days = date1.daysTo(date2);
  10.  
  11.  
  12. if(days < 0)
  13. {
  14.  
  15. temp = date1;
  16. date1 = date2;
  17. date2 = temp;
  18. }
  19.  
  20.  
  21. Date2.clear();
  22.  
  23. }
  24.  
  25. Date1.clear();
  26. }
To copy to clipboard, switch view to plain text mode 

I would appreciate any help.

Many thanks in advance!