Results 1 to 4 of 4

Thread: Array Sort- issue

  1. #1
    thinBasic MVPs ReneMiner's Avatar
    Join Date
    Oct 2012
    Location
    Germany
    Age
    48
    Posts
    1,241
    Blog Entries
    1
    Rep Power
    136

    Array Sort- issue

    If i do some
    Array Sort ..., AsFiles
    
    (see images, check filelist low-left)

    on a string-array (that contains filenames) it does not ignore LCase/Ucase but sorts the filenames starting with UCase-chars, thereafter follow the filenames starting with LCase-chars in most cases.

    Sometimes it does not even follow that rule but messes up the order completely. (image 2, where i sort standard previously and then AsFiles)
    I found out that it sorts by LENGTH if using Ascend or Descend

    Is there a way to simply sort by alphabet - no matter if UCase or LCase-char?
    ( Collate Ucase ??? )

    Another example:
    Help says
    A standard order would sort the above list in the following way While using ASFILES it will sort considering the numeric part be a number
    Picture1.jpg
    Picture10.jpg
    Picture11.jpg
    Picture12.jpg
    Picture2.jpg
    Picture3.jpg
    Picture4.jpg
    Picture5.jpg
    Picture6.jpg
    Picture7.jpg
    Picture8.jpg
    Picture9.jpg
    Picture1.jpg
    Picture2.jpg
    Picture3.jpg
    Picture4.jpg
    Picture5.jpg
    Picture6.jpg
    Picture7.jpg
    Picture8.jpg
    Picture9.jpg
    Picture10.jpg
    Picture11.jpg
    Picture12.jpg
    but in case one filename (or common string) starts with a lower-case "p" it will get sorted to the end mostly.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	array_sort_asFiles.png 
Views:	85 
Size:	32.7 KB 
ID:	9338   Click image for larger version. 

Name:	array_sort_asFiles2.png 
Views:	87 
Size:	39.7 KB 
ID:	9339  
    Last edited by ReneMiner; 03-11-2015 at 15:08.
    maybe no PC currently but always a head full of ideas

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,343
    Blog Entries
    2
    Rep Power
    10
    Let me check what I can do.
    Maybe I can add COLLATE UCASE ...
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    51
    Posts
    8,343
    Blog Entries
    2
    Rep Power
    10
    Rene,

    try attached 1.9.16.1 thinCore.dll (copy into your \thinBasic\ directory replacing your current one).
    I've added Collate Ucase option to Array Sort and also adjust AsFiles option that I think had a bug.

    If all OK I will publish an update: 1.9.16.2
    Let me know.

    Ciao
    Eros




    Examples of new syntax. If you DEBUG and step by step inspect sourceArray array you will see the difference:
    Uses "Console"
    
    Dim sourceArray(10)       As String
    
    Array Assign sourceArray(1) = 
      "tUI.tBasicU", 
      "tNode.tbasicu",
      "tMouse.tBasicU",
      "tWindow.tBasicU",
      "Fontslot.tBasicU",
      "Settings.tBasicU",
      "tControl_Label.tBasicU",
      "tControl_PopUp.tBasicU",
      "tControl_Button.tBasicU",
      "tDesktop.tBasicU"
      
    Array Sort sourcearray(), Collate Ucase, AsFiles 
    Array Sort sourcearray(), Collate Ucase, Descending, AsFiles 
    Array Sort sourcearray(), Collate Ucase
    
    Array Assign sourceArray(1) = 
      "tUI10.tBasicU", 
      "tUI1.tBasicU", 
      "tUI2.tBasicU", 
      "tUI3.tBasicU", 
      "tUI4.tBasicU", 
      "tUI22.tBasicU", 
      "tUI6.tBasicU", 
      "tUI7.tBasicU", 
      "tUI8.tBasicU", 
      "tUI5.tBasicU"
    
    Array Sort sourcearray(), Collate Ucase, Ascending, AsFiles 
    Array Sort sourcearray(), Collate Ucase, Descending, AsFiles 
    Array Sort sourcearray(), Collate Ucase, AsFiles 
    Array Sort sourcearray(), Collate Ucase
    Array Sort sourcearray(), Descending
    Array Sort sourcearray()
    
    Print "---All done---"
    WaitKey
    
    Attached Files Attached Files
    Last edited by ErosOlmi; 10-10-2017 at 08:05.
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  4. #4
    thinBasic MVPs ReneMiner's Avatar
    Join Date
    Oct 2012
    Location
    Germany
    Age
    48
    Posts
    1,241
    Blog Entries
    1
    Rep Power
    136
    That looks much better, mille grazie
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	aaawsome.png 
Views:	56 
Size:	40.5 KB 
ID:	9343  
    Last edited by ReneMiner; 04-11-2015 at 11:00.
    maybe no PC currently but always a head full of ideas

Similar Threads

  1. copy array of UDT to another array in one step?
    By ReneMiner in forum thinBasic General
    Replies: 3
    Last Post: 02-11-2012, 01:15
  2. Replacing ARRAY SORT
    By MikeTrader in forum Power Basic
    Replies: 9
    Last Post: 28-08-2009, 22:57
  3. TBJ: little section for next issue
    By ErosOlmi in forum Suggest new articles
    Replies: 2
    Last Post: 27-07-2008, 09:12
  4. PCOPY! Issue #70 now available.
    By MystikShadows in forum PCOPY!
    Replies: 5
    Last Post: 20-06-2008, 20:50

Posting Permissions

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