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:
qSort(list.benin(), list.end())
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.
for(int g = 0; g<list.size()-1; g++)
{
Date1 = list[g];
for(int l = g+1; l<list.size(); l++)
{
Date2 = list[l];
days = date1.daysTo(date2);
if(days < 0)
{
temp = date1;
date1 = date2;
date2 = temp;
}
Date2.clear();
}
Date1.clear();
}
for(int g = 0; g<list.size()-1; g++)
{
Date1 = list[g];
for(int l = g+1; l<list.size(); l++)
{
Date2 = list[l];
days = date1.daysTo(date2);
if(days < 0)
{
temp = date1;
date1 = date2;
date2 = temp;
}
Date2.clear();
}
Date1.clear();
}
To copy to clipboard, switch view to plain text mode
I would appreciate any help.
Many thanks in advance!
Bookmarks