Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Re: Sorting Algorithms

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Sorting Algorithms

    I have to sort a list on Parent Child relation
    say
    I have a following list
    Object(Id,ParentId,.........)
    obj1(1,1,........);
    obj2(2,1,........);
    obj3(3,3,........);
    obj4(4,1,........);
    obj5(5,3,........);
    obj6(6,1,........);
    obj7(7,3,........);
    obj8(8,4,........);

    Logic is such that
    If Id and Parent Id is same then It is Parent Record
    I want the Result like
    obj1(1,1,........);
    obj2(2,1,........);
    obj4(4,1,........);
    obj6(6,1,........);
    obj3(3,3,........);
    obj5(5,3,........);
    obj7(7,3,........);
    obj8(8,4,........);


    Suggect Some Logic...............

    Thanks in advance.............


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Sorting Algorithms

    Moved to Java Theory & Questions

    What have you tried so far? How are you sorting? See Comparator (Java Platform SE 6) and http://www.javaworld.com/javaworld/j...1227-sort.html

Similar Threads

  1. Threaded algorithms
    By TerTer in forum Algorithms & Recursion
    Replies: 0
    Last Post: April 20th, 2010, 08:34 AM
  2. Page Replacement Algorithms
    By smokeyjoey in forum Algorithms & Recursion
    Replies: 2
    Last Post: December 7th, 2009, 10:38 PM
  3. Sorting Algorithms
    By Dalisra in forum Java Programming Tutorials
    Replies: 1
    Last Post: November 10th, 2009, 09:24 PM
  4. Logic to implement a program to display decimal place of a number
    By chronoz13 in forum Algorithms & Recursion
    Replies: 2
    Last Post: June 11th, 2009, 03:53 AM
  5. Java algorithm for bank program to connect database
    By araujo3rd in forum Algorithms & Recursion
    Replies: 1
    Last Post: December 10th, 2008, 01:34 PM