Provides IComparer and IComparer<string> implementations to sort strings in a "natural" fashion.
This type is thread safe.
"Natural" string comparison compares strings as humans would compare them, not as computers do. Thus the string "10" sorts after "2", whereas "normally" "10" would sort before "2" because normal string comparison works a character at a time, and "1" is before "2".
Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0
See Also: Inherited members from object.
⊟ Public Properties
[read-only] staticDefault NaturalStringComparer . Returns the default Cadenza.NaturalStringComparer instance to use for comparing strings. ⊟ Public Methods
⊟ Explicitly Implemented Interface Members
IComparer.Compare Returns the sort order of two object instances. ⊟ Extension Methods
staticJust<T> (this T) : Maybe<T> Create a new Cadenza.Maybe<T> instance initialized to a specified value. The returned value will not be Maybe<T>.Nothing. staticMatch<TSource,TResult> (this TSource, params Func<TSource, Maybe<TResult>>[]) : TResult Converts the TSource instance self into a TResult. staticToMaybe<T> (this T) : Maybe<T> Create a new Cadenza.Maybe<T> instance initialized to a specified value. The returned value may be Maybe<T>.Nothing. staticTraverseBreadthFirst<TSource,TResult> (this TSource, Func<TSource, TResult>, Func<TSource, IEnumerable<TSource>>) : IEnumerable<TResult> Traverse a tree in a breadth-first fashion, converting each encountered node. staticTraverseBreadthFirstWithParent<TSource,TResult> (this TSource, Func<TSource, TResult>, Func<TSource, IEnumerable<TSource>>) : IEnumerable<KeyValuePair<TSource, TResult>> Traverse a tree in a breadth-first fashion, converting each encountered node. staticTraverseDepthFirst<TSource,TResult> (this TSource, Func<TSource, TResult>, Func<TSource, IEnumerable<TSource>>) : IEnumerable<TResult> Traverse a tree in a depth-first fashion, converting each encountered node. staticTraverseDepthFirstWithParent<TSource,TResult> (this TSource, Func<TSource, TResult>, Func<TSource, IEnumerable<TSource>>) : IEnumerable<KeyValuePair<TSource, TResult>> Traverse a tree in a depth-first fashion, converting each encountered node. staticWith<TSource,TResult> (this TSource, Func<TSource, TResult>) : TResult Supports chaining otherwise temporary values.
⊟ Compare Method
Returns the sort order of two string instances.
⊟ Parameters
⊟ Returns
The return value is a negative number, zero, or a positive number reflecting the sort order of a as compared to b. For non-zero return values, the exact value returned by this method is unspecified. The following table defines the return value:
Value Condition A negative number a < b. Zero a == b. A positive number a > b. Note: A null reference is considered to compare less than any other non-null object, and equal to any other null reference, independent of the underlying Type of either object.⊟ Remarks
This method compares x to y using a "natural" string comparison algorithm, so that strings with embedded numeric data sort by the numeric data in conjunction with the surrounding string, instead of treating the numeric data as part of the string itself.
This allows "foo10" to sort after "foo2", as is usually expected when looking at sorted text, instead of having "foo10" sort before "foo2", as Comparer<string> would do.
⊟ Requirements
Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0
⊟ Default Property
Returns the default Cadenza.NaturalStringComparer instance to use for comparing strings.
public static NaturalStringComparer Default { get; }⊟ Value
A Cadenza.NaturalStringComparer instance to use for comparing strings.⊟ Remarks
This field is read-only.⊟ Requirements
Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0
⊟ System.Collections.IComparer.Compare Method
Returns the sort order of two object instances.
⊟ Parameters
⊟ Returns
The return value is a negative number, zero, or a positive number reflecting the sort order of a as compared to b. For non-zero return values, the exact value returned by this method is unspecified. The following table defines the return value:
Value Condition A negative number a < b. Zero a == b. A positive number a > b. Note: A null reference is considered to compare less than any other non-null object, and equal to any other null reference, independent of the underlying Type of either object.⊟ Remarks
This method calls NaturalStringComparer.Compare(string, string), passing x.ToString() and y.ToString() as arguments.⊟ Requirements
Namespace: Cadenza
Assembly: Cadenza (in Cadenza.dll)
Assembly Versions: 0.1.0.0