Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sort keyset of Hashtable

 
Stefan Nie´┐Żner
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!

i'm using midp2.0 and i want to know if there is any possibility do sort the keys of a hashtable.
i know, that in j2se exists the collection.sort() - method, but i've nothing found for midp.

thanks in advance, stefan
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like there's nothing to do this directly in MIDP 2.0. Probably the easiest way to handle this is to write your own sort() implementation, and then use it to sort a Vector or array of the keys. There are many ways to implement a sort, of course - but a quick way might be to just look at the source code used by Arrays.sort(). It just calls a private mergeSort() method which is fairly simple to duplicate.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic