Show / Hide Table of Contents

Class NaturalSortComparer

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

Inheritance
object
NaturalSortComparer
Implements
IComparer<string>
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
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
string x

The first object to compare.

string y

The second object to compare.

Returns
Type Description
int

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

IComparer<T>

Extension Methods

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