Link to home
Start Free TrialLog in
Avatar of BrianMc1958
BrianMc1958

asked on

Can a HashSet be ordered on a non-key field?

Dear Experts,

I have a HashSet containing "Customer" beans.  Each bean contains a CustName and a CustScore.  I override "equals" and "hash" using CustName only.  CustScore is just an ordinary field in the bean.

However, I now need to determine which customers were in the top 10% of CustScores.  I know I can do this by iterating the set, and then building and sorting internal arrays.  But I'm wondering if there is some way to directly tell the HashSet, "Give me all the customer beans in CustScore order"?

Thanks,
BrianMc1958
ASKER CERTIFIED SOLUTION
Avatar of Giant2
Giant2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:)

Regards,
Muruga
----------------------------------------------------------------------------
Tryout personalized emailing services at http://www.mailaide.com
:-)
Avatar of Giant2
Giant2

:)