Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Fastest way to sort a collection
Message
De
30/01/2013 18:52:17
 
 
À
30/01/2013 18:40:34
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01564757
Message ID:
01564771
Vues:
44
>If you know your collection is in ascending order and you want it descending, just reverse it (http://msdn.microsoft.com/en-us/library/b0axc2h2%28v=vs.90%29.aspx). Otherwise you can use the sort method (http://msdn.microsoft.com/en-us/library/3da4abas%28v=vs.90%29.aspx) to sort it, although you might need to create your own comparer. Or you could change your collection to a SortedList (http://msdn.microsoft.com/en-us/library/ms132319%28v=vs.90%29.aspx) so that the list is created in a sorted order.
>
>It might also help to know exactly what type of collection you are using, how you are sorting now that is too slow, and why your collection is composed of single element object arrays instead of strings.

The collection is defined like this:
        Public oDirectory As Collection = New Collection
The first link mentions the usage of a list approach. This is different in my case.

All collections are built to support undefined number of items. Here is an example:
        ' Add a parameter in a container for the data dictionary fields
        ' expC1 Field
        ' expO1 Value
        Private Function ParameterAddDataDictionaryField(ByVal tcField As String, ByVal toValue As Object) As Boolean
            Dim loParameter(1, 5) As Object

            ' Initialization
            loParameter(1, 1) = tcField
            loParameter(1, 2) = toValue
            loParameter(1, 3) = ""
            loParameter(1, 4) = ""
            loParameter(1, 5) = 0

            oParametersDataDictionaryField.Add(loParameter)

            Return True
        End Function
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform