I’m trying to get a directory listing and sort it into last modified time order using Vala.
I’ve got the directory listing part into a List < FileInfo >.
But I cannot figure out how to sort the list.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is done via the the
sort(CompareFunc<G> compare_func)method in theListclass. You can read more about it here.A basic example for strings would be:
The return value of the function passed to
sort()is the same as the ISO C90qsort(3)function:As you’re interested in modify time, the
FileAttributeyou’re looking for is TIME_MODIFIED which you would get by calling the appropriateget_attribute_*method ofFileInfo.