Sort both the strings to get the lexicographically smallest string possible
char [ ] a = str1 . ToCharArray ( ) ; Array . Sort ( a ) ; char [ ] b = str2 . ToCharArray ( ) ; Array . Sort ( b ) ; str1 = new String ( a ) ; str2 = new String ( b ) ;