Click here to Skip to main content
15,067,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using quicksort to sort my data in a listbox:
C#
ArrayList arr=new ArrayList();
arr.sort();
listbox1.datasource=arr;
But if I want to use bubble sort, what should i do?

Thanks
Posted
Updated 30-Apr-12 5:29am
v2
Comments
Sergey Alexandrovich Kryukov 30-Apr-12 12:43pm
   
Why do you want it? The only reason I can see is homework, but you want to do it by yourself.
--SA

Well, for a start, you should really ditch ArrayList. If you aren't using .NET 1/1.1, a strongly typed list is generally a better proposition. Now, if you want to use a Bubble sort, you are going to have to write one - there's not one built into the BCL.

But, are you really sure you want to Bubble sort? Bubble sorting isn't the most efficient way to sort.
   
Comments
[no name] 30-Apr-12 11:31am
   
*cough* homework
Pete O'Hanlon 30-Apr-12 11:37am
   
*discreet cough* that's what I figured. You may notice there's no code in there - just advice:)
h7h7h7 30-Apr-12 11:33am
   
dear Pete, no I won't use, I just want to compare bubble sort with quick sort and other sort.
thnx man :)
   
Comments
h7h7h7 30-Apr-12 11:34am
   
thnx man I found it in google, but there no examples hot to use bubble sort in windows form when data are in a listbox ??
Sergey Alexandrovich Kryukov 30-Apr-12 12:45pm
   
What is "bubble sort in windows form"? Ever heard of separation of concerns. Don't through everything in one pile...
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900