Ask Experts Questions for FREE Help !
Ask
    Sagar1988's Avatar
    Sagar1988 Posts: 1, Reputation: 1
    New Member
     
    #1

    Jun 30, 2015, 01:04 AM
    How to sort the generic list based om condition
    If we have list as,
    Rollno name age address
    ====== ==== === =======
    01 abc 11 pqr
    02 stu 21 pqrWe are supposed to sort this list based on names. If the name of student is same then sort based on age and if age is also same then sort based on number. I am stuck on how to sort names The code that I have tried till is
    public void sortData(List<Student> studentList) {
    String a1=null;
    String a2[] = null;
    int I=0;
    for (Iterator<Student> iter = list.listIterator(); iter.hasNext();) {
    Student a = iter.next();
    System.out.println(a1 = a.getStudentName());

    }


    System.out.println(a2);
    }It is printing list of roll numbers but I am not getting how to sort them now.

Check out some similar questions!

(Based on marriage)-I applied for removal of condition in October 2011- I have been M [ 0 Answers ]

(Based on marriage)-I applied for removal of condition in October 2011- I have been Married for 3 years and half. They sent me a receipt saying my permanent resident has been extended for 1 year- My status online says - Initial review. My green card will expire on December 4th 2012. I was told that...

Sort a Column & sum the range with same value during the sort [ 2 Answers ]

Hi, I'm trying to sort a data table by Grades & then sum the totals of the cell with same Grade. The table consists of this headers: Date, DD#, Grade, Bags so what I'm trying to do is to come up with a formula that can sort by Grade & then add the total Bags against that particular Grade and...

I want a program that will sort a word list alphabetically [ 2 Answers ]

I have a site that you type in letters and it finds possible words for those letters... So then I copy it and paste it in notepad so I can work with it... But the problem Is that words are aligned with left edge of file and are not in alphabetic order... What I need is to run results...

Excel: Macro to designate a color based on condition [ 1 Answers ]

I have an Excel which has three column. First has name(which might repeat in the coming cells) ,second has condition and the third has color. I want to count the number of color for a particular condition against each name Thanks Bhaskar KP


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.