Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sort records Ascending order of precedence

Posted on 2007-08-08
8
Medium Priority
?
405 Views
Last Modified: 2013-12-14
Hi experts,

I have two different objects, for example


Ob1...................................................................

Attribute      (row 1)          (row 2)      (row 3)
First name      tom      harry      tom
Last name      bob      bob      jhon
Occupation      se      se      me
Company      abc      xyz      pqr
Address      aaa      sss      ddd
City      ccc      ccc      bbc
Country      rrr      aaa      zzz


Ob2................................................................

Attribute      (row 4)      (row 5)         (row 6)
First name      tom      joe      tom
middle name      bob      bob      jhon
Address      aaa      sss      ddd
City      ccc      aam      ccc
state      rrr      aaa      zzz


Now I need sort all the six records in the following order (Ascending order of precedence)

First name
City


Can someone help me &
0
Comment
Question by:ksanjiv
6 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 19659665
0
 

Author Comment

by:ksanjiv
ID: 19659677
using Comparator i can compare only ... how will i sort the records .... can u write a sample code.... wud be helpful to me
0
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 500 total points
ID: 19659790
to sort, use Arrays.sort(list, comparator);
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 17

Expert Comment

by:contactkarthi
ID: 19662134
can you post the expected result.. like u want them in a single object or the values should be sorted and the be rearranged with 3 sets in each obbject
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 500 total points
ID: 19663011
Although you show it rotated, what you have there is effectively a TableModel. The following deals with sorting TableModel. You can ignore the gui parts:

http://www.bastie.de/java/howto/swing/table/sorttable.html
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20213341
Forced accept.

Computer101
EE Admin
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month21 days, 2 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question