Interface ICharsSorter
An algorithm sorting the chars of the provided string.
Namespace: MoreStructures.Strings.Sorting
Assembly: MoreStructures.dll
Syntax
public interface ICharsSorter
Methods
| Improve this Doc View SourceSort(String)
Sorts the chars of input
, returning the list of positions of each of the chars in
input
(i.e. the System.Int32 value item of the order list O at index i, O[i], is the
position in the input
string, of the System.Char in the sorted string at index i).
Declaration
IList<int> Sort(string input)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The string whose System.Char items have to be sorted. |
Returns
Type | Description |
---|---|
IList<System.Int32> | A list of position in the sorted string: 0 being the first in the order, 1 the second, etc. |
Examples
Sorting the input string "cabcba"
gives the position list { 1, 5, 2, 4, 0, 5 }
, because:
- the sorted string is
"aabbcc"
; - the System.Char in the sorted string at index 0 is
'a'
and the position in theinput
string of the first'a'
is1
; - the System.Char in the sorted string at index 1 is
'a'
and the position in theinput
string of the second'a'
is5
; - the System.Char in the sorted string at index 2 is
'b'
and the position in theinput
string of the first'b'
is2
; - etc.