Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

LinkedList  RSS feed

 
kirba devi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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

0-box,1-test,2-f_next,3-image.gif



Regards
Kirba.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
kirba devi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Regards
Kirba.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!