Sorting string's characters according to their ASCII values#363
Sorting string's characters according to their ASCII values#363ChetanKarwa wants to merge 1 commit into
Conversation
|
Hello @ChetanKarwa, great to see you managed to build stdlib and get your new function working. However, I am not totally convinced by the purpose of this function. The more common usage of a sort function would be to sort a list of strings (like the one in development in #311), say to output a sorted list of labels. Do you have some usage cases that motivate a character sort function? |
|
I implemented this because I've seen other languages supporting the sorting of a character array. |
|
@wclodius2 Is your implementation related to this PR? |
|
No, it isn't. My sort is of an array of elements of the |
|
I renamed this PR to avoid confusion with #408 |
|
What could be done is to provide the O(n) sorting algorithm of @ChetanKarwa as a specialization in #408 when the input is an array of The only usage I can think of currently is to find the median letter (and maybe the mode) in a character sequence. |
|
Also, consider that this implementation is likely to fail for non-ASCII input: print *, sort("Ångström")
! Fortran runtime error: Index '195' of dimension 1 of array 'count' above upper bound of 128 |
I have implemented a sort function for a string. This function sorts the string's characters according to their ASCII values.
Eg:
string - "This is to be sorted"
sorted string - " Tbdeehiioorssstt"