Results 1 to 5 of 5

Thread: Sorteren stringlist.

  1. #1

    Sorteren stringlist.

    Kan ik bij het sorteren van een stringlist ook aangegeven dat hij het eerste karakter moet overslaan en dat hij vanaf het tweede karakter begint te sorteren?
    Niets is zo gemakkelijk als het lijkt.

  2. #2
    John Kuiper
    Join Date
    Apr 2007
    Location
    Almere
    Posts
    8,747
    Je zou de custumsort kunnen gebruiken
    Code:
    Description
    
    Use CustomSort to sort the strings in the list, where the sort order is defined by the Compare parameter. 
    
    Supply a value for the Compare function that compares two strings in the string list. The List parameter provides access to the string list, while the Index1 and Index2 parameters identify the strings to be compared. Use Index1 and Index2 as indexes into the Strings property array. The Compare function should return
    
    a value less than 0 if the string identified by Index1 comes before the string identified by Index2
    	0 if the two strings are equivalent
    	a value greater than 0 if the string with Index1 comes after the string identified by Index2.
    Do not pass nil as the value of the Compare parameter.
    
    Note:	You must explicitly call the CustomSort method. Setting the Sorted property only sorts strings using ANSI order, as implemented in the Sort method.
    Delphi is great. Lazarus is more powerfull

  3. #3
    Bedankt zal kijken of ik het met customsort kan oplossen.
    Niets is zo gemakkelijk als het lijkt.

  4. #4
    Het nadeel van/verschil met CustomSort, is dat de lijst niet gesorteerd blijft bij het toevoegen van dingen, en misschien zelfs wel niet als gesorteerd wordt gezien bij het zoeken (weet ik niet uit m'n hoofd).

    CustomSort aanroepen is vergelijkbaar met Sort aanroepen, en staat dus los van de sorted property die de lijst gesorteerd houdt, ook na bewerkingen erop.
    1+1=b

  5. #5
    Quote Originally Posted by GolezTrol View Post
    Het nadeel van/verschil met CustomSort, is dat de lijst niet gesorteerd blijft bij het toevoegen van dingen
    Dat is geen probleem. Ga na het sorteren ook niets meer toevoegen.
    Niets is zo gemakkelijk als het lijkt.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •