Sort each string in descending order
char [ ] temp = s . ToCharArray ( ) ; Array . Sort ( temp ) ; int st = 0 ; int ed = temp . Length - 1 ; while ( st < ed ) { char ch = temp [ st ] ; temp [ st ] = temp [ ed ] ; temp [ ed ] = ch ; st ++ ; ed -- ; } string charsStr = new string ( temp ) ; sort ( s . begin ( ) , s . end ( ) , greater < char > ( ) ) ;