473,385 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Sort an arraylist

I have a class that looks like

Public Class Number
Public Index As Int16
Public Appears As Int16
Public Ratio As Single
Public Sub New(ByVal index As Int16, ByVal appears As Int16, ByVal ratio
As Single)
Me.Index = index
Me.Appears = appears
Me.Ratio = ratio
End Sub

I have an arraylist that stores 50+ of these classes. I need to sort this
arraylist by Ratio. Can someone point me to an example of this other than
the microsoft example
http://msdn.microsoft.com/library/de...ssorttopic.asp
which shows how to sort just one thing inside the arraylist.

--
Poor planning on your part does not constitute an emergency on my part.
Dec 25 '06 #1
2 1240
Here are two examples:

By David Hayden:
http://codebetter.com/blogs/david.ha.../06/56584.aspx
By Matt Bourne: http://blogs.worldnomads.com.au/matt...icles/187.aspx

Both in C# but easy to convert to VB.NET.

Regards,

Plamen Ratchev
http://www.SQLStudio.com
"Its me Earnest T." <sp**@myplaceinspace.comwrote in message
news:45***********************@roadrunner.com...
>I have a class that looks like

Public Class Number
Public Index As Int16
Public Appears As Int16
Public Ratio As Single
Public Sub New(ByVal index As Int16, ByVal appears As Int16, ByVal
ratio As Single)
Me.Index = index
Me.Appears = appears
Me.Ratio = ratio
End Sub

I have an arraylist that stores 50+ of these classes. I need to sort this
arraylist by Ratio. Can someone point me to an example of this other than
the microsoft example
http://msdn.microsoft.com/library/de...ssorttopic.asp
which shows how to sort just one thing inside the arraylist.

--
Poor planning on your part does not constitute an emergency on my part.

Dec 26 '06 #2
Thanks
"Plamen Ratchev" <Pl****@SQLStudio.comwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
Here are two examples:

By David Hayden:
http://codebetter.com/blogs/david.ha.../06/56584.aspx
By Matt Bourne: http://blogs.worldnomads.com.au/matt...icles/187.aspx

Both in C# but easy to convert to VB.NET.

Regards,

Plamen Ratchev
http://www.SQLStudio.com
"Its me Earnest T." <sp**@myplaceinspace.comwrote in message
news:45***********************@roadrunner.com...
>>I have a class that looks like

Public Class Number
Public Index As Int16
Public Appears As Int16
Public Ratio As Single
Public Sub New(ByVal index As Int16, ByVal appears As Int16, ByVal
ratio As Single)
Me.Index = index
Me.Appears = appears
Me.Ratio = ratio
End Sub

I have an arraylist that stores 50+ of these classes. I need to sort
this arraylist by Ratio. Can someone point me to an example of this
other than the microsoft example
http://msdn.microsoft.com/library/de...ssorttopic.asp
which shows how to sort just one thing inside the arraylist.

--
Poor planning on your part does not constitute an emergency on my part.


Dec 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Leon | last post by:
I have six textbox controls on my webform that allows the user to enter any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
3
by: Adam J. Schaff | last post by:
Hello. I recently noticed that the Sort method of the .NET ArrayList class does not behave as I expected. I expect 'A' < '_' < 'a' (as per their ascii values) but what I got was the opposite....
19
by: Derek Martin | last post by:
Hi there, I have been playing with sorting my arraylist and having some troubles. Maybe just going about it wrong. My arraylist contains objects and one of the members of the object is 'name.' I...
0
by: Grant Wickman | last post by:
Our team has just fixed a really nasty problem that appears to be caused by an obscure bug in the sort method of Arraylist and daisy-chained webservice stubs. We've fixed the bug so I'll not...
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
4
by: M Harvey | last post by:
I have an arraylist that contains datetime values. What is the best way to sort this arraylist by date ascending? Thanks, Matt
3
by: jtfaulk | last post by:
Re: ArrayList, Sort, Menu, IComparer, Object, multidemensional I have a multi-dimensional arraylist, and I would like to sort one level of it but not all. The multi-dimensional arraylist...
4
by: rn5a | last post by:
Can the items in a ListBox be sorted by the name of the items? The ListBox actually lists all directories & files existing in a directory on the server. Note that all the directories should be...
3
by: djp | last post by:
Hi I have to sort arraylist. I tried to do this using this page as a reference: http://www.java2s.com/Code/CSharp/Collections-Data-Structure/UseIComparer.htm I did it exactly the same way but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.