13 types derived from Comparer
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (1)
LanguageServer\AbstractLanguageServerProtocolTests.cs (1)
105private protected class OrderLocations : Comparer<LSP.Location>
System.Collections (1)
System\Collections\Generic\SortedDictionary.cs (1)
838public sealed class KeyValuePairComparer : Comparer<KeyValuePair<TKey, TValue>>
System.Linq.Parallel (5)
System\Linq\Parallel\Utils\Util.cs (5)
64private sealed class FastIntComparer : Comparer<int> 74private sealed class FastLongComparer : Comparer<long> 84private sealed class FastFloatComparer : Comparer<float> 94private sealed class FastDoubleComparer : Comparer<double> 104private sealed class FastDateTimeComparer : Comparer<DateTime>
System.Private.CoreLib (6)
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\Comparer.cs (5)
35internal sealed class ComparisonComparer<T> : Comparer<T> 55public sealed partial class GenericComparer<T> : Comparer<T> where T : IComparable<T>? 80public sealed class NullableComparer<T> : Comparer<T?>, ISerializable where T : struct 115public sealed partial class ObjectComparer<T> : Comparer<T> 131internal sealed partial class EnumComparer<T> : Comparer<T>, ISerializable where T : struct, Enum
src\System\Collections\Generic\Comparer.CoreCLR.cs (1)
15internal sealed partial class EnumComparer<T> : Comparer<T> where T : struct, Enum
331 references to Comparer
Microsoft.AspNetCore.App.Analyzers.Test (1)
RouteEmbeddedLanguage\Infrastructure\MarkupTestFile.cs (1)
88var orderedMatches = matches.OrderBy(t => t, Comparer<(int matchIndex, string name)>.Create((t1, t2) => t1.matchIndex - t2.matchIndex)).ToList();
Microsoft.AspNetCore.Components (1)
Routing\RouteTableFactory.cs (1)
26public static readonly IComparer<InboundRouteEntry> RouteOrder = Comparer<InboundRouteEntry>.Create((x, y) =>
Microsoft.AspNetCore.Routing (6)
Matching\DfaMatcherBuilder.cs (4)
96var precedenceDigitComparer = Comparer<DfaBuilderWorkerWorkItem>.Create((x, y) => 166private readonly Comparer<DfaBuilderWorkerWorkItem> _precedenceDigitComparer; 172Comparer<DfaBuilderWorkerWorkItem> precedenceDigitComparer,
Matching\HostMatcherPolicy.cs (2)
426var result = Comparer<string>.Default.Compare(Host, other.Host); 432return Comparer<int?>.Default.Compare(Port, other.Port);
Microsoft.Build (9)
BackEnd\Components\Scheduler\Scheduler.cs (2)
1025return Comparer<int>.Default.Compare(_schedulingData.GetConfigurationsCountByNode(left, true /* excludeTraversals */, _configCache), _schedulingData.GetConfigurationsCountByNode(right, true /* excludeTraversals */, _configCache)); 1309return Comparer<int>.Default.Compare(configurationCountsByNode[left], configurationCountsByNode[right]);
BackEnd\Components\Scheduler\SchedulingPlan.cs (6)
114configurationsInOrder.Sort((KeyValuePair<int, double> l, KeyValuePair<int, double> r) => Comparer<int>.Default.Compare(l.Key, r.Key)); 237projectsInOrderOfTotalPlanTime.Sort((left, right) => Comparer<double>.Default.Compare(right.Value.TotalPlanTime, left.Value.TotalPlanTime)); 260projectsInOrderOfImmediateChildCount.Sort((left, right) => Comparer<int>.Default.Compare(right.Value.ReferencesCount, left.Value.ReferencesCount)); 276projectsInOrderOfReference.Sort(delegate (int left, int right) { return -Comparer<int>.Default.Compare(_configIdToPaths[left].Count, _configIdToPaths[right].Count); }); 337projectsByExpense.Sort(delegate (PlanConfigData left, PlanConfigData right) { return -Comparer<double>.Default.Compare(left.AccumulatedTime, right.AccumulatedTime); }); 345pathsByLength.Sort(delegate (Stack<PlanConfigData> left, Stack<PlanConfigData> right) { return Comparer<int>.Default.Compare(left.Count, right.Count); });
Evaluation\Expander.cs (1)
5586private static IComparer<MemberInfo> LongBeforeDoubleComparer => s_comparerLongBeforeDouble ??= Comparer<MemberInfo>.Create((key0, key1) => SelectTypeOfFirstParameter(key0).CompareTo(SelectTypeOfFirstParameter(key1)));
Microsoft.Build.Engine.UnitTests (1)
Evaluation\SimpleVersion_Tests.cs (1)
128Assert.Equal(expectedSign, Comparer<SimpleVersion>.Default.Compare(version1, version2));
Microsoft.Build.Framework (7)
ArraySortHelper.cs (6)
34comparer ??= Comparer<T>.Default; 51comparer ??= Comparer<T>.Default; 296if (comparer == null || comparer == Comparer<T>.Default) 342if (comparer == null || comparer == Comparer<T>.Default) 675IntrospectiveSort(keys, values, comparer ?? Comparer<TKey>.Default); 901if (comparer == null || comparer == Comparer<TKey>.Default)
SegmentedList`1.cs (1)
1110SegmentedArray.Sort<T>(_items, 0, _size, Comparer<T>.Create(comparison));
Microsoft.CodeAnalysis (18)
Collections\ImmutableArrayExtensions.cs (1)
1229comparer ??= Comparer<T>.Default;
CommandLine\AnalyzerConfig.cs (2)
106internal static Comparer<AnalyzerConfig> DirectoryLengthComparer { get; } = Comparer<AnalyzerConfig>.Create(
CommandLine\SarifV2ErrorLogger.cs (1)
389foreach (var severity in severities.OrderBy(Comparer<ReportDiagnostic>.Default))
InternalUtilities\EnumerableExtensions.cs (7)
603return source.OrderBy(Comparer<T>.Create(compare)); 608return source.OrderByDescending(Comparer<T>.Create(compare)); 617return source.OrderBy(Comparer<T>.Default); 627return source.ThenBy(Comparer<T>.Create(compare)); 632return source.ThenBy(Comparer<T>.Default); 643comparer ??= Comparer<T>.Default; 679return Comparer<T>.Create(comparison);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (6)
36comparer ??= Comparer<T>.Default; 53comparer ??= Comparer<T>.Default; 299if (comparer == null || comparer == Comparer<T>.Default) 345if (comparer == null || comparer == Comparer<T>.Default) 677IntrospectiveSort(keys, values, comparer ?? Comparer<TKey>.Default); 901if (comparer == null || comparer == Comparer<TKey>.Default)
src\Dependencies\PooledObjects\ArrayBuilder.cs (1)
316Sort(Comparer<T>.Create(compare));
Microsoft.CodeAnalysis.CodeStyle (17)
src\Compilers\Core\Portable\Collections\ImmutableArrayExtensions.cs (1)
1229comparer ??= Comparer<T>.Default;
src\Compilers\Core\Portable\InternalUtilities\EnumerableExtensions.cs (7)
603return source.OrderBy(Comparer<T>.Create(compare)); 608return source.OrderByDescending(Comparer<T>.Create(compare)); 617return source.OrderBy(Comparer<T>.Default); 627return source.ThenBy(Comparer<T>.Create(compare)); 632return source.ThenBy(Comparer<T>.Default); 643comparer ??= Comparer<T>.Default; 679return Comparer<T>.Create(comparison);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (6)
36comparer ??= Comparer<T>.Default; 53comparer ??= Comparer<T>.Default; 299if (comparer == null || comparer == Comparer<T>.Default) 345if (comparer == null || comparer == Comparer<T>.Default) 677IntrospectiveSort(keys, values, comparer ?? Comparer<TKey>.Default); 901if (comparer == null || comparer == Comparer<TKey>.Default)
src\Dependencies\PooledObjects\ArrayBuilder.cs (1)
316Sort(Comparer<T>.Create(compare));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\ImmutableIntervalTree`1.cs (1)
79Debug.Assert(values.IsSorted(Comparer<T>.Create((t1, t2) => localIntrospector.GetSpan(t1).Start - localIntrospector.GetSpan(t2).Start)));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\FixedSizeArrayBuilder.cs (1)
87=> Sort(Comparer<T>.Default);
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (1)
167? Comparer<object>.Default.Compare(f1.ConstantValue, f2.ConstantValue!)
Microsoft.CodeAnalysis.Collections.Package (6)
Internal\ArraySortHelper.cs (6)
36comparer ??= Comparer<T>.Default; 53comparer ??= Comparer<T>.Default; 299if (comparer == null || comparer == Comparer<T>.Default) 345if (comparer == null || comparer == Comparer<T>.Default) 677IntrospectiveSort(keys, values, comparer ?? Comparer<TKey>.Default); 901if (comparer == null || comparer == Comparer<TKey>.Default)
Microsoft.CodeAnalysis.CSharp.Features (1)
Organizing\Organizers\MemberDeclarationsOrganizer.Comparer.cs (1)
94if ((compare = Comparer<bool>.Default.Inverse().Compare(xIsStatic, yIsStatic)) != 0)
Microsoft.CodeAnalysis.EditorFeatures (2)
Extensibility\NavigationBar\WrappedNavigationBarItem.cs (1)
41spans.SortAndRemoveDuplicates(Comparer<TextSpan>.Default);
IntelliSense\AsyncCompletion\ItemManager.cs (1)
193return Comparer<RoslynCompletionItem>.Default.Compare(xRoslyn, yRoslyn);
Microsoft.CodeAnalysis.Features (7)
EditAndContinue\ActiveStatementsMap.cs (5)
25public static readonly Comparer<ActiveStatement> Comparer = 26Comparer<ActiveStatement>.Create((x, y) => x.FileSpan.Start.CompareTo(y.FileSpan.Start)); 28private static readonly Comparer<(ManagedActiveStatementDebugInfo, SourceFileSpan, ActiveStatementId)> s_infoSpanComparer = 29Comparer<(ManagedActiveStatementDebugInfo, SourceFileSpan span, ActiveStatementId)>.Create((x, y) => x.span.Start.CompareTo(y.span.Start)); 250Debug.Assert(builder.IsSorted(Comparer<UnmappedActiveStatement>.Create((x, y) => x.UnmappedSpan.Start.CompareTo(y.UnmappedSpan.End))));
EditAndContinue\DocumentAnalysisResults.cs (1)
156Debug.Assert(lineEditsOpt.All(documentLineEdits => documentLineEdits.LineUpdates.IsSorted(Comparer<SourceLineUpdate>.Create(
Structure\Syntax\AbstractBlockStructureProvider.cs (1)
19private static readonly IComparer<BlockSpan> s_blockSpanComparer = Comparer<BlockSpan>.Create(static (x, y) => y.TextSpan.Start.CompareTo(x.TextSpan.Start));
Microsoft.CodeAnalysis.InteractiveHost (1)
src\Dependencies\PooledObjects\ArrayBuilder.cs (1)
316Sort(Comparer<T>.Create(compare));
Microsoft.CodeAnalysis.PooledObjects.Package (1)
ArrayBuilder.cs (1)
316Sort(Comparer<T>.Create(compare));
Microsoft.CodeAnalysis.Test.Utilities (1)
Diagnostics\CommonDiagnosticAnalyzers.cs (1)
395foreach (var effectiveSeverity in effectiveSeverities.OrderBy(Comparer<ReportDiagnostic>.Default))
Microsoft.CodeAnalysis.UnitTests (11)
Collections\ArrayBuilderTests.cs (6)
60builder.SortAndRemoveDuplicates(Comparer<int>.Default); 64builder.SortAndRemoveDuplicates(Comparer<int>.Default); 68builder.SortAndRemoveDuplicates(Comparer<int>.Default); 72builder.SortAndRemoveDuplicates(Comparer<int>.Default); 76builder.SortAndRemoveDuplicates(Comparer<int>.Default); 80builder.SortAndRemoveDuplicates(Comparer<int>.Default);
Collections\ImmutableListTestBase.cs (2)
428comparer = Comparer<int>.Create(comparison); 488inputData = inputData.Sort(sortedIndex, sortedLength, Comparer<int>.Default);
Collections\List\SegmentedList.Generic.Tests.Sort.cs (2)
37IComparer<T> comparer = Comparer<T>.Default; 51IComparer<T> comparer = Comparer<T>.Default;
Collections\List\TestBase.Generic.cs (1)
44protected virtual IComparer<T> GetIComparer() => Comparer<T>.Default;
Microsoft.CodeAnalysis.Workspaces (18)
src\Compilers\Core\Portable\Collections\ImmutableArrayExtensions.cs (1)
1229comparer ??= Comparer<T>.Default;
src\Compilers\Core\Portable\InternalUtilities\EnumerableExtensions.cs (7)
603return source.OrderBy(Comparer<T>.Create(compare)); 608return source.OrderByDescending(Comparer<T>.Create(compare)); 617return source.OrderBy(Comparer<T>.Default); 627return source.ThenBy(Comparer<T>.Create(compare)); 632return source.ThenBy(Comparer<T>.Default); 643comparer ??= Comparer<T>.Default; 679return Comparer<T>.Create(comparison);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (6)
36comparer ??= Comparer<T>.Default; 53comparer ??= Comparer<T>.Default; 299if (comparer == null || comparer == Comparer<T>.Default) 345if (comparer == null || comparer == Comparer<T>.Default) 677IntrospectiveSort(keys, values, comparer ?? Comparer<TKey>.Default); 901if (comparer == null || comparer == Comparer<TKey>.Default)
src\Dependencies\PooledObjects\ArrayBuilder.cs (1)
316Sort(Comparer<T>.Create(compare));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\ImmutableIntervalTree`1.cs (1)
79Debug.Assert(values.IsSorted(Comparer<T>.Create((t1, t2) => localIntrospector.GetSpan(t1).Start - localIntrospector.GetSpan(t2).Start)));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\FixedSizeArrayBuilder.cs (1)
87=> Sort(Comparer<T>.Default);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (1)
167? Comparer<object>.Default.Compare(f1.ConstantValue, f2.ConstantValue!)
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (16)
src\Compilers\Core\Portable\Collections\ImmutableArrayExtensions.cs (1)
1229comparer ??= Comparer<T>.Default;
src\Compilers\Core\Portable\InternalUtilities\EnumerableExtensions.cs (7)
603return source.OrderBy(Comparer<T>.Create(compare)); 608return source.OrderByDescending(Comparer<T>.Create(compare)); 617return source.OrderBy(Comparer<T>.Default); 627return source.ThenBy(Comparer<T>.Create(compare)); 632return source.ThenBy(Comparer<T>.Default); 643comparer ??= Comparer<T>.Default; 679return Comparer<T>.Create(comparison);
src\Dependencies\Collections\Internal\ArraySortHelper.cs (6)
36comparer ??= Comparer<T>.Default; 53comparer ??= Comparer<T>.Default; 299if (comparer == null || comparer == Comparer<T>.Default) 345if (comparer == null || comparer == Comparer<T>.Default) 677IntrospectiveSort(keys, values, comparer ?? Comparer<TKey>.Default); 901if (comparer == null || comparer == Comparer<TKey>.Default)
src\Dependencies\PooledObjects\ArrayBuilder.cs (1)
316Sort(Comparer<T>.Create(compare));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\FixedSizeArrayBuilder.cs (1)
87=> Sort(Comparer<T>.Default);
Microsoft.Data.Analysis (8)
DataFrameColumns\StringDataFrameColumn.cs (2)
207var comparer = Comparer<string>.Default;
PrimitiveDataFrameColumn.cs (4)
698Comparer<T> comparer = Comparer<T>.Default; 731Comparer<T> comparer = Comparer<T>.Default;
PrimitiveDataFrameColumn.Sort.cs (2)
23var comparer = Comparer<T>.Default;
Microsoft.ML.Core (2)
CommandLine\CmdParser.cs (1)
1259Array.Sort(args, 0, args.Length, Comparer<Arg>.Create((x, y) => x.SortOrder.CompareTo(y.SortOrder)));
Utilities\VBufferUtils.cs (1)
327pred = pred ?? ((ref T val) => Comparer<T>.Default.Compare(val, default(T)) == 0);
Microsoft.ML.Data (3)
Prediction\Calibrator.cs (2)
1395var comp = Comparer<DataItem>.Create((x, y) => x.Score.CompareTo(y.Score));
Transforms\InvertHashUtils.cs (1)
208Array.Sort(buffer, 0, count, Comparer<Pair>.Create((x, y) => x.Order - y.Order));
Microsoft.ML.FastTree (2)
FastTreeRanking.cs (1)
996Comparer<int>.Create((x, y) =>
Training\EnsembleCompression\LassoBasedEnsembleCompressor.cs (1)
102return Comparer<double>.Default.Compare(c1.Value, c2.Value);
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
87[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.Comparer<>))]
netstandard (1)
netstandard.cs (1)
106[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.Comparer<>))]
System.Collections (21)
artifacts\obj\System.Collections\Debug\net10.0\System.Collections.Forwards.cs (1)
4[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Collections.Generic.Comparer<>))]
System\Collections\Generic\PriorityQueue.cs (12)
94/// Uses <see cref="Comparer{T}.Default" /> if the argument is <see langword="null"/>. 109/// Uses <see cref="Comparer{T}.Default" /> if the argument is <see langword="null"/>. 147/// Uses <see cref="Comparer{T}.Default" /> if the argument is <see langword="null"/>. 177public IComparer<TPriority> Comparer => _comparer ?? Comparer<TPriority>.Default; 274if (Comparer<TPriority>.Default.Compare(priority, root.Priority) > 0) 369if (Comparer<TPriority>.Default.Compare(priority, root.Priority) > 0) 540if (Comparer<TPriority>.Default.Compare(lastNode.Priority, priority) < 0) 731if (Comparer<TPriority>.Default.Compare(node.Priority, parent.Priority) < 0) 804if (Comparer<TPriority>.Default.Compare(nextChild.Priority, minChild.Priority) < 0) 812if (Comparer<TPriority>.Default.Compare(node.Priority, minChild.Priority) <= 0) 916if (comparer == Comparer<TPriority>.Default) 930return comparer ?? Comparer<TPriority>.Default;
System\Collections\Generic\SortedDictionary.cs (1)
844this.keyComparer = keyComparer ?? Comparer<TKey>.Default;
System\Collections\Generic\SortedList.cs (2)
78comparer = Comparer<TKey>.Default; 93comparer = Comparer<TKey>.Default;
System\Collections\Generic\SortedSet.cs (3)
73comparer = Comparer<T>.Default; 78this.comparer = comparer ?? Comparer<T>.Default; 82public SortedSet(IEnumerable<T> collection) : this(collection, Comparer<T>.Default) { }
System\Collections\Generic\SortedSetEqualityComparer.cs (1)
26_comparer = comparer ?? Comparer<T>.Default;
System\Collections\StructuralComparisons.cs (1)
74return Comparer<object>.Default.Compare(x, y);
System.Collections.Immutable (29)
System\Collections\Frozen\SmallValueTypeComparableFrozenDictionary.cs (2)
49if (Comparer<TKey>.Default.Compare(key, _max) <= 0) 54int c = Comparer<TKey>.Default.Compare(key, keys[i]);
System\Collections\Frozen\SmallValueTypeComparableFrozenSet.cs (2)
44if (Comparer<T>.Default.Compare(item, _max) <= 0) 49int c = Comparer<T>.Default.Compare(item, items[i]);
System\Collections\Immutable\ImmutableArray_1.Builder.cs (1)
949Array.Sort(_elements, 0, this.Count, Comparer<T>.Default);
System\Collections\Immutable\ImmutableArray_1.cs (3)
789return self.Sort(0, self.Length, Comparer<T>.Default); 806return self.Sort(Comparer<T>.Create(comparison)); 835comparer ??= Comparer<T>.Default;
System\Collections\Immutable\ImmutableList_1.Builder.cs (2)
894/// elements, or null to use <see cref="Comparer{T}.Default"/>. 913/// elements, or null to use <see cref="Comparer{T}.Default"/>.
System\Collections\Immutable\ImmutableList_1.cs (7)
65/// The default comparer <see cref="Comparer{T}.Default"/> cannot 78/// elements.-or-null to use the default comparer <see cref="Comparer{T}.Default"/>. 87/// <paramref name="comparer"/> is null, and the default comparer <see cref="Comparer{T}.Default"/> 103/// elements, or null to use the default comparer <see cref="Comparer{T}.Default"/>. 118/// <paramref name="comparer"/> is null, and the default comparer <see cref="Comparer{T}.Default"/> 449/// elements, or null to use the default comparer <see cref="Comparer{T}.Default"/>. 466/// elements, or null to use the default comparer <see cref="Comparer{T}.Default"/>.
System\Collections\Immutable\ImmutableList_1.Node.cs (6)
562internal Node Sort() => this.Sort(Comparer<T>.Default); 589/// elements, or null to use the default comparer <see cref="Comparer{T}.Default"/>. 606/// elements, or null to use the default comparer <see cref="Comparer{T}.Default"/>. 632/// elements, or null to use the default comparer <see cref="Comparer{T}.Default"/>. 647/// <paramref name="comparer"/> is null, and the default comparer <see cref="Comparer{T}.Default"/> 655comparer ??= Comparer<T>.Default;
System\Collections\Immutable\ImmutableSortedDictionary_2.Builder.cs (1)
39private IComparer<TKey> _keyComparer = Comparer<TKey>.Default;
System\Collections\Immutable\ImmutableSortedDictionary_2.cs (2)
53_keyComparer = keyComparer ?? Comparer<TKey>.Default; 323keyComparer ??= Comparer<TKey>.Default;
System\Collections\Immutable\ImmutableSortedSet_1.Builder.cs (1)
41private IComparer<T> _comparer = Comparer<T>.Default;
System\Collections\Immutable\ImmutableSortedSet_1.cs (2)
58_comparer = comparer ?? Comparer<T>.Default; 349comparer ??= Comparer<T>.Default;
System.Data.Common (1)
System\Data\EnumerableRowCollection.cs (1)
289AddSortExpression<TKey>(keySelector, Comparer<TKey>.Default, isDescending, isOrderBy);
System.Diagnostics.DiagnosticSource (2)
System\Diagnostics\Metrics\InstrumentAdvice.cs (2)
59Comparer<T> comparer = Comparer<T>.Default;
System.Linq (63)
System\Linq\Max.cs (22)
330comparer ??= Comparer<TSource>.Default; 333if (typeof(TSource) == typeof(byte) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<byte, MaxCalc<byte>>((IEnumerable<byte>)source); 334if (typeof(TSource) == typeof(sbyte) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<sbyte, MaxCalc<sbyte>>((IEnumerable<sbyte>)source); 335if (typeof(TSource) == typeof(ushort) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<ushort, MaxCalc<ushort>>((IEnumerable<ushort>)source); 336if (typeof(TSource) == typeof(short) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<short, MaxCalc<short>>((IEnumerable<short>)source); 337if (typeof(TSource) == typeof(char) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<char, MaxCalc<char>>((IEnumerable<char>)source); 338if (typeof(TSource) == typeof(uint) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<uint, MaxCalc<uint>>((IEnumerable<uint>)source); 339if (typeof(TSource) == typeof(int) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<int, MaxCalc<int>>((IEnumerable<int>)source); 340if (typeof(TSource) == typeof(ulong) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<ulong, MaxCalc<ulong>>((IEnumerable<ulong>)source); 341if (typeof(TSource) == typeof(long) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<long, MaxCalc<long>>((IEnumerable<long>)source); 342if (typeof(TSource) == typeof(nuint) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<nuint, MaxCalc<nuint>>((IEnumerable<nuint>)source); 343if (typeof(TSource) == typeof(nint) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<nint, MaxCalc<nint>>((IEnumerable<nint>)source); 344if (typeof(TSource) == typeof(Int128) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<Int128, MaxCalc<Int128>>((IEnumerable<Int128>)source); 345if (typeof(TSource) == typeof(UInt128) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<UInt128, MaxCalc<UInt128>>((IEnumerable<UInt128>)source); 380if (comparer == Comparer<TSource>.Default) 385if (Comparer<TSource>.Default.Compare(next, value) > 0) 445comparer ??= Comparer<TKey>.Default; 497if (comparer == Comparer<TKey>.Default) 503if (Comparer<TKey>.Default.Compare(nextKey, key) > 0) 852Comparer<TResult> comparer = Comparer<TResult>.Default; 873if (Comparer<TResult>.Default.Compare(x, value) > 0)
System\Linq\Min.cs (22)
308comparer ??= Comparer<TSource>.Default; 311if (typeof(TSource) == typeof(byte) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<byte, MinCalc<byte>>((IEnumerable<byte>)source); 312if (typeof(TSource) == typeof(sbyte) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<sbyte, MinCalc<sbyte>>((IEnumerable<sbyte>)source); 313if (typeof(TSource) == typeof(ushort) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<ushort, MinCalc<ushort>>((IEnumerable<ushort>)source); 314if (typeof(TSource) == typeof(short) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<short, MinCalc<short>>((IEnumerable<short>)source); 315if (typeof(TSource) == typeof(char) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<char, MinCalc<char>>((IEnumerable<char>)source); 316if (typeof(TSource) == typeof(uint) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<uint, MinCalc<uint>>((IEnumerable<uint>)source); 317if (typeof(TSource) == typeof(int) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<int, MinCalc<int>>((IEnumerable<int>)source); 318if (typeof(TSource) == typeof(ulong) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<ulong, MinCalc<ulong>>((IEnumerable<ulong>)source); 319if (typeof(TSource) == typeof(long) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<long, MinCalc<long>>((IEnumerable<long>)source); 320if (typeof(TSource) == typeof(nuint) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<nuint, MinCalc<nuint>>((IEnumerable<nuint>)source); 321if (typeof(TSource) == typeof(nint) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<nint, MinCalc<nint>>((IEnumerable<nint>)source); 322if (typeof(TSource) == typeof(Int128) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<Int128, MinCalc<Int128>>((IEnumerable<Int128>)source); 323if (typeof(TSource) == typeof(UInt128) && comparer == Comparer<TSource>.Default) return (TSource)(object)MinMaxInteger<UInt128, MinCalc<UInt128>>((IEnumerable<UInt128>)source); 358if (comparer == Comparer<TSource>.Default) 363if (Comparer<TSource>.Default.Compare(next, value) < 0) 423comparer ??= Comparer<TKey>.Default; 475if (comparer == Comparer<TKey>.Default) 481if (Comparer<TKey>.Default.Compare(nextKey, key) < 0) 815Comparer<TResult> comparer = Comparer<TResult>.Default; 836if (Comparer<TResult>.Default.Compare(x, value) < 0)
System\Linq\OrderBy.cs (6)
24/// This method compares elements by using the default comparer <see cref="Comparer{T}.Default"/>. 43/// If comparer is <see langword="null"/>, the default comparer <see cref="Comparer{T}.Default"/> is used to compare elements. 46TypeIsImplicitlyStable<T>() && (comparer is null || comparer == Comparer<T>.Default) ? 69/// This method compares elements by using the default comparer <see cref="Comparer{T}.Default"/>. 88/// If comparer is <see langword="null"/>, the default comparer <see cref="Comparer{T}.Default"/> is used to compare elements. 91TypeIsImplicitlyStable<T>() && (comparer is null || comparer == Comparer<T>.Default) ?
System\Linq\OrderedEnumerable.cs (11)
89_comparer = comparer ?? Comparer<TKey>.Default; 101if (typeof(TKey) == typeof(string) && comparer == Comparer<string>.Default) 189new CachingComparer<TElement, TElement>(EnumerableSorter<TElement>.IdentityFunc, Comparer<TElement>.Default, _descending) : 190new CachingComparerWithChild<TElement, TElement>(EnumerableSorter<TElement>.IdentityFunc, Comparer<TElement>.Default, _descending, childComparer); 193new EnumerableSorter<TElement, TElement>(EnumerableSorter<TElement>.IdentityFunc, Comparer<TElement>.Default, _descending, next); 240span.Sort(static (a, b) => Comparer<TElement>.Default.Compare(b, a)); 449Debug.Assert(_comparer == Comparer<TKey>.Default); 456int c = Comparer<TKey>.Default.Compare(keys[index1], keys[index2]); 465Debug.Assert(_comparer == Comparer<TKey>.Default); 472int c = Comparer<TKey>.Default.Compare(keys[index2], keys[index1]); 484if (typeof(TKey).IsValueType && _next is null && _comparer == Comparer<TKey>.Default)
System\Linq\OrderedEnumerable.SpeedOpt.cs (2)
414if (Comparer<TElement>.Default.Compare(nextValue, resultValue) < 0) 425if (Comparer<TElement>.Default.Compare(nextValue, resultValue) >= 0)
System.Linq.Parallel (10)
System\Linq\Parallel\Enumerables\AggregationMinMaxHelpers.cs (2)
63Comparer<T> comparer = Util.GetDefaultComparer<T>(); 87Comparer<T> comparer = Util.GetDefaultComparer<T>();
System\Linq\Parallel\QueryOperators\Binary\GroupJoinQueryOperator.cs (1)
160return CreateComparer(Comparer<bool>.Default, comparer);
System\Linq\Parallel\Utils\Util.cs (7)
36internal static Comparer<TKey> GetDefaultComparer<TKey>() 40return (Comparer<TKey>)(object)s_fastIntComparer; 44return (Comparer<TKey>)(object)s_fastLongComparer; 48return (Comparer<TKey>)(object)s_fastFloatComparer; 52return (Comparer<TKey>)(object)s_fastDoubleComparer; 56return (Comparer<TKey>)(object)s_fastDateTimeComparer; 59return Comparer<TKey>.Default;
System.Private.CoreLib (59)
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs (6)
25comparer ??= Comparer<T>.Default; 42comparer ??= Comparer<T>.Default; 287if (comparer == null || comparer == Comparer<T>.Default) 331if (comparer == null || comparer == Comparer<T>.Default) 621IntrospectiveSort(keys, values, comparer ?? Comparer<TKey>.Default); 838if (comparer == null || comparer == Comparer<TKey>.Default)
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\Comparer.cs (2)
16public static Comparer<T> Create(Comparison<T> comparison) 97if (y.HasValue) return Comparer<T>.Default.Compare(x.value, y.value);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs (1)
5658sortedChannels.Sort((p1, p2) => -Comparer<ulong>.Default.Compare(p1.Value.Keywords, p2.Value.Keywords));
src\libraries\System.Private.CoreLib\src\System\Nullable.cs (1)
83if (n2.HasValue) return Comparer<T>.Default.Compare(n1.value, n2.value);
src\libraries\System.Private.CoreLib\src\System\Tuple.cs (8)
140return CompareTo(obj, Comparer<object>.Default); 260return CompareTo(obj, Comparer<object>.Default); 385return CompareTo(obj, Comparer<object>.Default); 520return CompareTo(obj, Comparer<object>.Default); 665return CompareTo(obj, Comparer<object>.Default); 820return CompareTo(obj, Comparer<object>.Default); 985return ((IStructuralComparable)this).CompareTo(obj, Comparer<object>.Default); 1165return CompareTo(obj, Comparer<object>.Default);
src\libraries\System.Private.CoreLib\src\System\ValueTuple.cs (37)
323return Comparer<T1>.Default.Compare(Item1, objTuple.Item1); 342return Comparer<T1>.Default.Compare(Item1, other.Item1); 533int c = Comparer<T1>.Default.Compare(Item1, other.Item1); 536return Comparer<T2>.Default.Compare(Item2, other.Item2); 724int c = Comparer<T1>.Default.Compare(Item1, other.Item1); 727c = Comparer<T2>.Default.Compare(Item2, other.Item2); 730return Comparer<T3>.Default.Compare(Item3, other.Item3); 931int c = Comparer<T1>.Default.Compare(Item1, other.Item1); 934c = Comparer<T2>.Default.Compare(Item2, other.Item2); 937c = Comparer<T3>.Default.Compare(Item3, other.Item3); 940return Comparer<T4>.Default.Compare(Item4, other.Item4); 1156int c = Comparer<T1>.Default.Compare(Item1, other.Item1); 1159c = Comparer<T2>.Default.Compare(Item2, other.Item2); 1162c = Comparer<T3>.Default.Compare(Item3, other.Item3); 1165c = Comparer<T4>.Default.Compare(Item4, other.Item4); 1168return Comparer<T5>.Default.Compare(Item5, other.Item5); 1399int c = Comparer<T1>.Default.Compare(Item1, other.Item1); 1402c = Comparer<T2>.Default.Compare(Item2, other.Item2); 1405c = Comparer<T3>.Default.Compare(Item3, other.Item3); 1408c = Comparer<T4>.Default.Compare(Item4, other.Item4); 1411c = Comparer<T5>.Default.Compare(Item5, other.Item5); 1414return Comparer<T6>.Default.Compare(Item6, other.Item6); 1660int c = Comparer<T1>.Default.Compare(Item1, other.Item1); 1663c = Comparer<T2>.Default.Compare(Item2, other.Item2); 1666c = Comparer<T3>.Default.Compare(Item3, other.Item3); 1669c = Comparer<T4>.Default.Compare(Item4, other.Item4); 1672c = Comparer<T5>.Default.Compare(Item5, other.Item5); 1675c = Comparer<T6>.Default.Compare(Item6, other.Item6); 1678return Comparer<T7>.Default.Compare(Item7, other.Item7); 1945int c = Comparer<T1>.Default.Compare(Item1, other.Item1); 1948c = Comparer<T2>.Default.Compare(Item2, other.Item2); 1951c = Comparer<T3>.Default.Compare(Item3, other.Item3); 1954c = Comparer<T4>.Default.Compare(Item4, other.Item4); 1957c = Comparer<T5>.Default.Compare(Item5, other.Item5); 1960c = Comparer<T6>.Default.Compare(Item6, other.Item6); 1963c = Comparer<T7>.Default.Compare(Item7, other.Item7); 1966return Comparer<TRest>.Default.Compare(Rest, other.Rest);
src\System\Collections\Generic\Comparer.CoreCLR.cs (2)
12public static Comparer<T> Default { [Intrinsic] get; } = (Comparer<T>)ComparerHelpers.CreateDefaultComparer(typeof(T));
src\System\Collections\Generic\ComparerHelpers.cs (2)
10/// Helper class for creating the default <see cref="Comparer{T}"/> and <see cref="EqualityComparer{T}"/>. 21/// Creates the default <see cref="Comparer{T}"/>.
System.Threading.Channels (2)
System\Threading\Channels\Channel.netcoreapp.cs (2)
14/// <see cref="Comparer{T}.Default"/> is used to determine priority of elements. 26/// or <see cref="Comparer{T}.Default"/> if the provided comparer is null.
System.Windows.Forms (1)
System\Windows\Forms\Layout\TableLayout.SorterObjectArray.cs (1)
16comparer ??= Comparer<LayoutInfo>.Default;
System.Windows.Forms.Tests (1)
System\Windows\Forms\TreeViewTests.cs (1)
7125IComparer treeSorter = Comparer<object>.Create(