Introduction
Here's an IComparer
that implements the spec as I understand it. It uses a Regular Expression to find the indices of the first uppercase letters.
namespace PIEBALD.Types
{
public sealed class WackyComparer : System.Collections.Generic.IComparer<string>
{
private static readonly System.Text.RegularExpressions.Regex reg ;
static WackyComparer
(
)
{
reg = new System.Text.RegularExpressions.Regex ( "[A-Z]" ) ;
return ;
}
public int
Compare
(
string Op0
,
string Op1
)
{
int result = 0 ;
System.Text.RegularExpressions.Match mat ;
int index0 = ( mat = reg.Match ( Op0 )).Success ? mat.Index : System.Int32.MaxValue ;
int index1 = ( mat = reg.Match ( Op1 )).Success ? mat.Index : System.Int32.MaxValue ;
if ( ( result = index0 - index1 ) == 0 )
{
result = Op0.CompareTo ( Op1 ) ;
}
return ( result ) ;
}
}
}