Results 1 to 40 of 68

Thread: Sorting algorithms (sort array)

Threaded View

  1. #11
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Sorting algorithms

    Quote Originally Posted by Lord Orwell
    strcomp didn't work too well for strings of different lengths. This subroutine sorts everything, even numbers properly, because numbers are lower in the ascii set. And it ignores upper and lower case, but as you can see from the code this can be changed.
    Listview also failed on something else: I show a directory with it and the . and .. entries get moved from the top. Or i want directories listed first. All in all it is a really weak routine and if you want to fix any of its shortcomings you have to disable it altogether or it resorts everything you fix.

    As for the function name suggesting anything, feel free to rename it to isitalphnumericalized. I wrote it years ago and i knew i would need a descriptive sub name so i used one
    Then the problem wasnt with the listview or its sorting algorithm, technically there was no problem... but rather you wanted a sort order different to ascii or a sort order where some items remain where they are (unsorted). Same can be said of number sorting, only text sort is provided cause the data is stored in the listview as string anyway (listviuew.Text property, .Substring() etc).

    It seems you misunderstood what I meant with it fails sorting numbers, dates, etc. I meant this output 1, 11, 12, 2, 20, 3 instead of 1, 2, 3, 11, 12, 20 cause they are treated as text. I don't see how your algorithm performs otherwise as your also using strings and comparing from the first character.

    Also, I'm surprised that you still havent encountered an error with Asc("") using your code when its supposed to handle two strings of different lengths. Not really being particular this moment on naming convention or shortcomings, but an error is an error.

    With regard to the thread topic, for speed consideration of sorting algo you want to simplify the comparison, and not only minimize the number of comparisons made, as much as possible...
    Last edited by leinad31; Jun 9th, 2007 at 04:05 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width