Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have gather a data which contain date,desc,status etc.
The data that I retrieve is not sorted.
How can I sort data by in arraylist by date?
My date format is M/d/yyyy

My sample data from arraylist:

SQL
Date      Status   Code      Description
1/1/2013  B        12010     Tunggakan
9/14/2013 R        11030     Cukai Semasa
7/1/2013  B        11010     Waran


The result should be:

SQL
Date      Status   Code      Description
1/1/2013  B        12010     Tunggakan
7/1/2013  B        11010     Waran
9/14/2013 R        11030     Cukai Semasa




Or can I put sort bydate asc in my query? Which one is the best approach?
Posted

1 solution

Yes, the best approach is to let your database do what it's best at - retrieving, sorting, grouping data... all usually more efficient in your database than anywhere else.

Throw the sort clause onto your query and it should be all good.
 
Share this answer
 
Comments
Luiey Ichigo 2-Oct-13 23:25pm    
Yup sir,

I guess the best approach is sort automatically when query the data.tq
Sergey Alexandrovich Kryukov 3-Oct-13 1:12am    
Good idea, a 5.
Besides, OP should not use ArrayList, it is obsolete...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900