The Artima Developer Community
Sponsored Link

Java Answers Forum
Sorting an ArrayList using

2 replies on 1 page. Most recent reply: Sep 21, 2004 11:07 PM by Mele2004m

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
grace

Posts: 1
Nickname: grace01
Registered: Sep, 2004

Sorting an ArrayList using Posted: Sep 4, 2004 11:41 AM
Reply to this message Reply
Advertisement
How can one change the following code for selection sort so it can be used with an ArrayList?
 selectionSort(int []array1)
     int index, min, temp;
     for (index=0, index < array1.lenght -1; index++)
      for (int j = array1 =1; j< array1.lenght; j++)
        if (array1[j], , array1[min]0
           {
            temp  = array1[min];
            array1[min] = array1[index];
            array1[index] = temp;
            }

Help, grace01


Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: Sorting an ArrayList using Posted: Sep 16, 2004 7:31 PM
Reply to this message Reply
if the ArrayList Name is myList then

array1.lenght = myList.size()
array1[j] = myList.get(j)

With that knowledge you should be able to convert it yourself

Mele2004m

Posts: 10
Nickname: nenny
Registered: Sep, 2004

Re: Using link list Posted: Sep 21, 2004 11:07 PM
Reply to this message Reply
Please can you send back a code for the Insert Last(int Key, int Age) method for a linked list,DisplayKey(int Key) method for a linked list,DeleteLast() method for a linked list and DeleteKey(int Key) method for a Sorted Link

Flat View: This topic has 2 replies on 1 page
Topic: What is java frame work and pattern ? Previous Topic   Next Topic Topic: **Urgent** How do I animate an image in here?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use