|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sorting a collection of collections?with manipulating data structure in vb.net. Imagine a Dictionary collection of Object "A". One of the properties of Object "A" is dictionaty collection of Object "B". Can I sort Object "A" using one of the properties within the collection of Objects "B"? Using the data structure below, a report has many lines, each line has many items, each item is made up of a current value and previous value. I want to sort the lines of the report using the current value of one of the items. Does this make any sense? Can it be done. I know there are people out there who live to figure out stuff like this (bless you... we need more of you). Thanks... Sherry <Serializable()> _ Public Class RptLines Inherits System.Collections.DictionaryBase Public Property Item(ByVal key As String) As RptLine Get Return DirectCast(Me.Dictionary.Item(key), RptLine) End Get Set(ByVal Value As RptLine) Me.Dictionary.Item(key) = Value End Set End Property Public Sub Add(ByVal key As String, ByVal value As RptLine) Me.Dictionary.Add(key, value) End Sub Public Function Contains(ByVal key As String) As Boolean Return Me.Dictionary.Contains(key) End Function Public Sub Remove(ByVal key As String) Me.Dictionary.Remove(key) End Sub Public Function Keys() As Collection Return Me.Keys End Function Public Function DictionaryHashtable() As Hashtable Return Me.InnerHashtable End Function End Class <Serializable()> _ Public Class RptLine Public Metrics() As RptItems Public Scope() As String End Class <Serializable()> _ Public Class RptItems Inherits System.Collections.DictionaryBase Default Public Property Item(ByVal key As String) As RptItem Get Return DirectCast(Me.Dictionary.Item(key), RptItem) End Get Set(ByVal Value As RptItem) Me.Dictionary.Item(key) = Value End Set End Property Public Sub Add(ByVal key As String, ByVal value As RptItem) Me.Dictionary.Add(key, value) End Sub Public Function Contains(ByVal key As String) As Boolean Return Me.Dictionary.Contains(key) End Function Public Sub Remove(ByVal key As String) Me.Dictionary.Remove(key) End Sub Public Function Keys() As Collection Return Me.Keys End Function End Class <Serializable()> _ Public Class RptItem Public Title() As String Public CurValue() As Single Public PrevValue() As Single End Class Hi,
I am not sure I have fully understood the problem... At first sight, it would seem natural to define A as a SortedList (where items are dictionary entries) and define a Comparer which uses the properties of objects B which you wish to use for ranking purposes... -tom One of the properties of Object "A" is Show quoteHide quote > dictionaty collection of Object "B". Can I sort Object "A" using one of > the properties within the collection of Objects "B"?
VB.NET INI or XML file for path locations
catching a specific exception Q: GIF image on a form Opening a MS Word document through a button click updating control on form2 from form1 Detect if compiling as a console application VB.NET: Implementing RasGetErrorString Get calling function in a function? about example code Copying a project into another solution |
|||||||||||||||||||||||