Forums Register Login

i have a list in that list have got files(image files ie image.gif,f_next.jpg) as well as dir(folder iemenu ,box,test..)

0 1 3 4
image.gif f_next.jpg box test

my problem is i want to arrange in a format like dir(folders) first then images.if i go for sorting(say ascending) it has to come in a format like


You mention a list of files ... are those real File objects? Or something else?

Is this the order you're looking for?

If so you may just be able to throw your File objects in a TreeSet and get them back sorted. If that's not quite what you want - it might be case sensitive - you can write your own Comparator to sort ignoring case.

Does that get you moving in the right direction?
Hi James,
You have understood wrongly.
List-- is nothing but the LinkedList list=new LinkedList()
In that list having
0-img1(Image reference)
1-dir(some folder)
2-img2(Image reference)
3-dir(some folder)

here in that list i want to sort images separately and dir separately

You didn't tell me he was so big. Unlike this tiny ad:
Become a Java guru with IntelliJ IDEA

This thread has been viewed 539 times.

All times above are in ranch (not your local) time.
The current ranch time is
Mar 23, 2019 05:22:55.