Results 1 to 2 of 2

Thread: ArrayList sort

  1. #1
    Dipke is offline Member
    Join Date
    Aug 2010
    Location
    Leuven, Belgium
    Posts
    86
    Rep Power
    0

    Question ArrayList sort

    Hi,

    I create an ArrayList with :
    Java Code:
    private ArrayList<Ploeg> ploegen;

    The class "Ploeg" has 2 attributes :
    Java Code:
     private String ploeg;
     private int punten;

    Then i fill in the ArrayList.

    How can i sort this list according the "punten" attribute ?

    Kind regards

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,004
    Blog Entries
    7
    Rep Power
    20

    Default

    Read the API documentation for the Comparable interface (which your Ploeg class should implement) or the Comparator interface. A Collection (such as an ArrayList) can sort those things.

    kind regards,

    Jos

Similar Threads

  1. how to sort an arraylist?
    By zhangster in forum New To Java
    Replies: 5
    Last Post: 03-19-2010, 08:01 AM
  2. Using Merge Sort to sort an ArrayList of Strings
    By coldfire in forum New To Java
    Replies: 3
    Last Post: 03-13-2009, 01:03 AM
  3. Replies: 2
    Last Post: 02-02-2009, 11:29 AM
  4. How to sort a list using Bubble sort algorithm
    By Java Tip in forum Algorithms
    Replies: 3
    Last Post: 04-29-2008, 08:04 PM
  5. Replies: 2
    Last Post: 04-21-2008, 11:43 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •