Show / Hide Table of Contents

Class NaturalSortComparer

Compares two string alpha-numeric with an inner number comparison.

Inheritance
System.Object
NaturalSortComparer
Implements
System.Collections.Generic.IComparer<System.String>
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Sartorius.SAF.Collections
Assembly: Sartorius.SAF.dll
Syntax
public class NaturalSortComparer : IComparer<string>
Examples

A list of strings: "a3", "a1", "a10", "a12", "a2", "a11", is sorted to: "a1", "a2", "a3", "a11", "a12", "a13". Traditionally the default string comparer sort it to: "a1", "a11", "a12", "a13", "a2", "a3"

Methods

View Source

Compare(String, String)

Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

Declaration
public int Compare(string x, string y)
Parameters
Type Name Description
System.String x

The first object to compare.

System.String y

The second object to compare.

Returns
Type Description
System.Int32

A signed integer that indicates the relative values of x and y, as shown in the following table.Value Meaning Less than zerox is less than y.Zerox equals y. Greater than zerox is greater than y.

Implements

System.Collections.Generic.IComparer<T>

Extension Methods

CollectionExtensions.AddRange<T, TCollection>(TCollection, IEnumerable<T>)
SerializableObjectCloneExtension.Clone<T>(T)
  • View Source
Back to top Generated by DocFX