I wrote this routine to order the item, just keep unique items, where it takes an array of type T , And after processing the size array it returns to the new size of the array.
Template & lt; Class T & gt; Int lower (T array [], integer shape) {t * start = array; T * end = array + size; Sort (start, end); T * end_new = Unique (start, end); Return end_new - array; } My question is that I was hoping that it would give it all the data like {"aa", "bb", " Bc "," ca "," bc "," aa "," cc "," cd "," ca "," bb "}; In AA Bbc BC CC CD
though it does in the opposite way: "CD CC CC BC Bb AA" Why does this happen? Does not it use standard string comparison? If I wanted to, how can I change it so that it would be described as described? Thank you.
sort () uses operator per default, which in your case only compares the addresses.
If you want to sort the c-string, then you must give a comparator to the sort () . To do this normally you can pass a comparator to the user, use expertise on a comparator function or one of these combinations:
template
Comments
Post a Comment