freelanceprogrammers.org Forum Index » Java

Can you Sort an ArrayList and Sorting a to z Questions.


View user's profile Post To page top
testthis222001 Posted: Sat Apr 17, 2004 3:56 pm


Joined: 14 Apr 2004

Posts: 6
Can you Sort an ArrayList and Sorting a to z Questions.
Does anybody know the answer to these two questions?
1) Can you sort an ArrayList?
(if so how - do you just use normal sorting algorithms, looping
through the array using something like selection/merge sort?)

2) Can you sort an ArrayList alphabetically?
(if so how do you do this?)

Thanks for any help
John
Reply with quote
Send private message
View user's profile Post To page top
only_4_frien... Posted: Sat Apr 17, 2004 8:49 pm


Joined: 17 Apr 2004

Posts: 1
Can you Sort an ArrayList and Sorting a to z Questions.
Ya u can sort the ArrayList using normal sorting
algorithm. Merge Sort will be better as it uses divide
and conquer approach.
answer to Q2. U can do one thing
dat retrieve the ascii code of each member of the
array list and those ranging in Ascii characters for
alphabets u can sort out the array alphabatically. Do
this yourself and if u cannt find it out reply me i
will again help u out.

--- testthis222001 <no_reply@yahoogroups.com> wrote:
> Does anybody know the answer to these two questions?
> 1) Can you sort an ArrayList?
> (if so how - do you just use normal sorting
> algorithms, looping
> through the array using something like
> selection/merge sort?)
>
> 2) Can you sort an ArrayList alphabetically?
> (if so how do you do this?)
>
> Thanks for any help
> John
>
>





__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html
Reply with quote
Send private message
View user's profile Post To page top
testthis222001 Posted: Sun Apr 18, 2004 5:36 am


Joined: 14 Apr 2004

Posts: 6
Can you Sort an ArrayList and Sorting a to z Questions.
Thanks for your help. I would be very greatful if you could help
with with the alphabatical sorting code. I should also mention that
what I need to do is sort each instance of a certain car (Sports,
Fancy or Luxury each has about 7 or some attributes that are common
to the Car super class, only these common instances need to be
sorted) by a certain attribute (One sort for price, and one sort for
Model - using the getPrice/Model methods). They need to then be
displayed in a textarea when a certain option is selected from a
JComboBox.

Also I am having trouble that when I press my save button for the
add car details the JList that displays them just shows one entry
the most recent car, it seems to be overriding the previous entries
(which should all be stored in the ArrayList). Do you know what
sort of issues can cause this? Is their a certain method or
something, in general areas to look at etc.

Thanks very much for your help, look foward to hearing from you
Regards John



--- In beginnersclub@yahoogroups.com, Ravi Kumar
<only_4_friendsin@y...> wrote:
> Ya u can sort the ArrayList using normal sorting
> algorithm. Merge Sort will be better as it uses divide
> and conquer approach.
> answer to Q2. U can do one thing
> dat retrieve the ascii code of each member of the
> array list and those ranging in Ascii characters for
> alphabets u can sort out the array alphabatically. Do
> this yourself and if u cannt find it out reply me i
> will again help u out.
>
> --- testthis222001 <no_reply@yahoogroups.com> wrote:
> > Does anybody know the answer to these two questions?
> > 1) Can you sort an ArrayList?
> > (if so how - do you just use normal sorting
> > algorithms, looping
> > through the array using something like
> > selection/merge sort?)
> >
> > 2) Can you sort an ArrayList alphabetically?
> > (if so how do you do this?)
> >
> > Thanks for any help
> > John
> >
> >
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online by April 15th
> http://taxes.yahoo.com/filing.html
Reply with quote
Send private message
View user's profile Post To page top
bobzcode Posted: Sun Apr 18, 2004 11:36 am


Joined: 18 Apr 2004

Posts: 6
Can you Sort an ArrayList and Sorting a to z Questions.
why is this email being sent out so many times

testthis222001 <no_reply@yahoogroups.com> wrote:Thanks for your help. I would
be very greatful if you could help
with with the alphabatical sorting code. I should also mention that
what I need to do is sort each instance of a certain car (Sports,
Fancy or Luxury each has about 7 or some attributes that are common
to the Car super class, only these common instances need to be
sorted) by a certain attribute (One sort for price, and one sort for
Model - using the getPrice/Model methods). They need to then be
displayed in a textarea when a certain option is selected from a
JComboBox.

Also I am having trouble that when I press my save button for the
add car details the JList that displays them just shows one entry
the most recent car, it seems to be overriding the previous entries
(which should all be stored in the ArrayList). Do you know what
sort of issues can cause this? Is their a certain method or
something, in general areas to look at etc.

Thanks very much for your help, look foward to hearing from you
Regards John



--- In beginnersclub@yahoogroups.com, Ravi Kumar
<only_4_friendsin@y...> wrote:
> Ya u can sort the ArrayList using normal sorting
> algorithm. Merge Sort will be better as it uses divide
> and conquer approach.
> answer to Q2. U can do one thing
> dat retrieve the ascii code of each member of the
> array list and those ranging in Ascii characters for
> alphabets u can sort out the array alphabatically. Do
> this yourself and if u cannt find it out reply me i
> will again help u out.
>
> --- testthis222001 <no_reply@yahoogroups.com> wrote:
> > Does anybody know the answer to these two questions?
> > 1) Can you sort an ArrayList?
> > (if so how - do you just use normal sorting
> > algorithms, looping
> > through the array using something like
> > selection/merge sort?)
> >
> > 2) Can you sort an ArrayList alphabetically?
> > (if so how do you do this?)
> >
> > Thanks for any help
> > John
> >
> >
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - File online by April 15th
> http://taxes.yahoo.com/filing.html


Yahoo! Groups SponsorADVERTISEMENT


---------------------------------
Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/beginnersclub/

To unsubscribe from this group, send an email to:
beginnersclub-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




---------------------------------
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢

[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
testthis222001 Posted: Sun Apr 18, 2004 4:02 pm


Joined: 14 Apr 2004

Posts: 6
Can you Sort an ArrayList and Sorting a to z Questions.
Search me mate. On my screen it only appread once and I only sent
it once. Seems odd to me. Has anybody else had this problem.
Because sometimes I have recieved the same email/post several
times. It just seems to happen randomly with Yahoo.
Reply with quote
Send private message
View user's profile Post To page top
dale_erwin Posted: Mon Apr 19, 2004 4:36 am


Joined: 11 Apr 2004

Posts: 11
Can you Sort an ArrayList and Sorting a to z Questions.
robert ryan wrote:
> why is this email being sent out so many times

Thanks for compounding the problem by quoting it in its entirety.
--
Dale Erwin
Salamanca 116
Pueblo Libre
Lima 21 PERU
Tel. +51(1)461-3084
Cel. +51(1)9743-6439
DALE ERWIN`S OPERA FILES - http://www.geocities.com/dale_erwin
Reply with quote
Send private message
View user's profile Post To page top
hazins Posted: Mon Apr 19, 2004 6:03 pm


Joined: 16 Apr 2004

Posts: 15
Can you Sort an ArrayList and Sorting a to z Questions.
Sorting ArrayList can be accomplished as follows:

ArrayList al = ... // your array list

// Convert it to array of whatever objects are in the ArrayList - for
generalazation I am assuming it`s Object
Object[] arrayOfObjects al.toArray();

// Sort the array
java.util.Arrays.sort(arrayOfObjects);

That`s that,
- Kalman



>>> only_4_friendsin@... 4/17/2004 11:49:23 AM >>>
Ya u can sort the ArrayList using normal sorting
algorithm. Merge Sort will be better as it uses divide
and conquer approach.
answer to Q2. U can do one thing
dat retrieve the ascii code of each member of the
array list and those ranging in Ascii characters for
alphabets u can sort out the array alphabatically. Do
this yourself and if u cannt find it out reply me i
will again help u out.

--- testthis222001 <no_reply@yahoogroups.com> wrote:
> Does anybody know the answer to these two questions?
> 1) Can you sort an ArrayList?
> (if so how - do you just use normal sorting
> algorithms, looping
> through the array using something like
> selection/merge sort?)
>
> 2) Can you sort an ArrayList alphabetically?
> (if so how do you do this?)
>
> Thanks for any help
> John
>
>





__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html


------------------------ Yahoo! Groups Sponsor


Yahoo! Groups Links
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help