#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    6
    Rep Power
    0

    Sorting a arraylist without using collections API in java


    I have an arraylist , i need to sort the list without using
    any collections API (like Collections.sort , Arrays.sort, TreeSet, HashSet etc.,) these library functions are restricted

    example:

    ArrayList aList = new ArrayList();
    aList.add("11");
    aList.add("21");
    aList.add("34");
    aList.add("8");

    I need to sort these list , kindly help required
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Iran
    Posts
    149
    Rep Power
    139
    Maybe the following (although it is written for C) can give you an idea.

    http://www.cprogramming.com/tutorial/computersciencetheory/sorting2.html

    Regards,
    Dariyoosh
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0
    Originally Posted by dariyoosh
    Maybe the following (although it is written for C) can give you an idea.

    (URL address blocked: See forum rules)

    Regards,
    Dariyoosh
    This is the Java forum - it is almost pointless linking him to a C solution when it isn't going to assist him in solving his problem.

    There are different kinds of sorting algorithms that you can use, such as a quick sort or merge sort.

    Code:
    http://www.cs.utsa.edu/~cs2123/lectures/week09.html
    That has some examples and questions that you can attempt to sort through your Array List.

    Hope this helps.
  6. #4
  7. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    You can use any sorting techinique you want. The ArrayList class defines a get and set method.

IMN logo majestic logo threadwatch logo seochat tools logo