CKTIS / C#
sorting and comparison: odniesienie praktyczne
sorting and comparison: odniesienie praktyczne: Sortowanie porządkuje elementy według spójnego komparatora i wybranej stabilności.
Wersja: C# language and .NET 10 reference runtime
Składnia
// sortingSortowanie porządkuje elementy według spójnego komparatora i wybranej stabilności.
Ustal klucze oraz kierunki jawnie; użyj ThenBy do kolejnych kluczy.
Niespójny comparer daje nieprzewidywalny wynik, a sortowanie może buforować całość.
Puste i jednoelementowe dane są już posortowane; null wymaga ustalonej kolejności.
Kompletny program rzeczywiście używa sorting and comparison; oczekiwany stdout to dokładnie 1,2,3.
Przykłady
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var values = new[] { 3, 1, 2 }; Array.Sort(values); Console.WriteLine(string.Join(",", values));
Wynik
1,2,3
Kompletny program rzeczywiście używa `sorting and comparison`; oczekiwany stdout to dokładnie `1,2,3`.