//
//
//DRF,FRD
//
string vText = @"ABCD,BDAC,DRF,FRD,CADB,CAADB,XB" ;
List < string > vResults = new List < string > ();
string [] vWords = vText . Split( "," . ToCharArray(),
StringSplitOptions . RemoveEmptyEntries);
foreach ( string vWord in vWords)
{
char [] vChars = vWord . ToUpper() . ToCharArray();
Array . Sort(vChars);
string T = new string (vChars);
bool vExists = false ;
for ( int i = 0 ; i < vResults . Count; i ++ )
if (T + "=" == vResults[i] . Substring( 0 , T . Length + 1 ))
{
vResults[i] += "," + vWord;
vExists = true ;
break ;
}
if ( ! vExists) vResults . Add(T + "=" + vWord);
}
int vGroup = 0 ;
foreach ( string vResult in vResults)
{
if (vResult . IndexOf( ',' ) > 0 )
{
vGroup ++ ;
textBox1 . AppendText( string . Format( "{0}{1}\r\n" ,
vGroup, vResult . Substring(vResult . IndexOf( '=' ) + 1 )));
}
}