How to sort Map?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I have
I want to display the Map entries according to the Long values, corresponding
to the String, in the ascending order.
Please suggest, the proper way to do so!
Thanks,
cmbhatt
[ April 09, 2007: Message edited by: Chandra Bhatt ]
cmbhatt
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
If it's keys, it's quite simple, just use a TreeMap.
But it it's about sorting by the values, hmm...
ASCII silly question, Get a silly ANSI.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Commons Collections
Cheers
ASCII silly question, Get a silly ANSI.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What if it is sort by values!
Stuart, you seem to me as fast as electricity. Before I could post, you had an
answer. Please suggest some conversion mechanism, converting values to list
and then sorting, then showing according to keys...
Isn't it?
Thanks,
cmbhatt
[ April 09, 2007: Message edited by: Chandra Bhatt ]
cmbhatt
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
let's see... can we use something other than a hashmap?
I can think of storing Map.Entry objects (if the HashMap object is already given to you, get the Entry object Set using the appropriate method)
in a List and sorting that list by using a custom Comparator which helps sort by Entry values.
Hope I am clear with the basic idea, but this is just a thought running in my head and I haven't considering all aspects of implementing it, but maybe you want to try some code taking this as a cue and we can discuss it further?
ASCII silly question, Get a silly ANSI.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
you might b looking for somthing like this.
SCJP5 95%, SCWCD 85%<br />Knowledge is the Life of Mind
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
That's true reply. That is what I was thinking of!
Thanks!
Regards,
cmbhatt
cmbhatt
-
-
Number of slices to send:Optional 'thank-you' note:
-
-

SCJP5 95%, SCWCD 85%<br />Knowledge is the Life of Mind
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
ASCII silly question, Get a silly ANSI.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Code compiles with warning!
I am trying to convert it to the form that compiles without warning(Java 5).
Thanks for reminding me!
Regards,
cmbhatt
cmbhatt
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Originally posted by Bert Bates:
Also, let's make any Apache code "out of bounds" for a discussion in the SCJP forum :roll:
Why??

ASCII silly question, Get a silly ANSI.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
In general, we like to reserve this forum for discussions that fall within the scope of topics that are covered in the exam. In this case, the relevent objective starts out:
"Use capabilities in the java.util package..."
Just trying to help everyone's studies be as efficient as possible
Thanks,
Bert
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
"Use capabilities in the java.util package..."
That is what my expectations were to have some solution straight from
java.util package. For current purpose (SCJP 5), people like me wont have
any interest to look forward for third party solutions.
My intention was to see how can we do that using java.util package.
Thanks,
cmbhatt
cmbhatt
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I agree -- and wholeheartedly, that the idea of this forum is to exercise one's own algorithmic skills within the bounds of the set objectives.
I was more in a developer mode than a certificate-aspirant one. I will recalibrate accordingly.
However, I reserve my old stand for just one reason: to those who may be willing to, poring over such pre-written code might give valuable ideas.
Of course, only Javafolk who have adequate experience in development would be amenable to doing this, and it seems to me that there are many here -- without being disparaging, who have less than a long-standing development experience. So, I guess I should mention such other pointers with the appropriate caveat!
ASCII silly question, Get a silly ANSI.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
In fact you could drop names if you want to, and if you do start another thread you could add the link to it here for those SCJP candidates who want to do a little "extra credit" studying
Bert
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
) Cheers.
ASCII silly question, Get a silly ANSI.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
| A magnificient life is loaded with tough challenges. En garde tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |









