Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Custom sorting algorithm
Message
De
04/05/2008 05:03:45
 
 
À
04/05/2008 02:34:32
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01315003
Message ID:
01315005
Vues:
17
>Hi,
>I have item as below:
>
>
>ItemName          BeforeItem    AfterItem
>------------------------------------------
>"First"
>"Second"
>"Third"
>"B4Second"        "Second"
>"BetweenSecond"   "Second"      "B4Second"
>
>
>
>I would like to implement IComparable to sort them so that it could be as below:
>
>First
>B4Second
>BetweenSecond
>Second
>Third
>
>Please advice

Don't see how you can use IComparable for this since CompareTo() has to provide a decision based solely on the value of two items and you're structure precludes that. Maybe iterate over the items and insert each into an ArrayList or similar?

Regards,
Viv
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform