Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack safer

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
012345678901234567890123456789012345678901234567890123456789
Yesterday
012345678901234567890123456789012345678901234567890123456789
Total views
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

Developer docs
Sorting
SortingReference implementationStep-by-step guideOfficial docs and resourcesDiscussionsComments

Other algorithms

Algorithm basics4
Complexity analysisSearchingBasic data structuresTrees and heaps
Core algorithms6
Graph traversalShortest paths & minimum spanning treesDynamic programmingGreedy algorithmsDivide and conquerBacktracking
Advanced algorithms5
String algorithmsMath and number theoryBit manipulationSegment treesUnion-find
Practical algorithms4
Coding interview strategyLRU cacheRate limitingConsistent hashing

Algorithm

Sorting

Sorting algorithms put data in order: merge sort, quicksort, heapsort, stability, the n log n lower bound, counting and radix sort, and built-in sorts.

Start the guideDiscussions

Sorting rearranges elements into a defined order such as numeric, alphabetical or chronological. Algorithms fall into two families: comparison sorts (bubble, insertion, selection, merge, quick and heap sort), which only ask whether one element comes before another, and non-comparison sorts such as counting sort and radix sort, which use integer values or their digits directly.

Sorting is the preparation step for binary search, deduplication, interval merging, rankings and much more, which is why it is among the first algorithms people study. Knowing the Ω(n log n) lower bound for comparison sorts, the difference between stable and in-place sorts, and how built-in sorts behave, such as Python's Timsort or the introsort used by most C++ std::sort implementations, helps you make the right call in production code and in coding interviews.

A good way to study it is to trace insertion sort, merge sort and quicksort by hand on small arrays, then implement merge sort and quicksort yourself and compare their best, average and worst cases. After that, practice sorting with key functions and comparators, and solve problems built on sorting, such as merging intervals and counting inversions.

On this page

  1. Highlights
  2. Where it is used
  3. Reference implementation
  4. Step-by-step guide
  5. Official docs and resources
  6. Discussions
  7. Comments

Highlights

Divide and conquer

Merge sort splits the input in half and merges the halves; quicksort partitions around a pivot. Both run in O(n log n) on average.

Stability and in-place sorting

A stable sort keeps elements with equal keys in their original order; an in-place sort needs almost no extra memory. Which one matters more depends on the task.

The Ω(n log n) lower bound

A decision-tree argument shows that any comparison sort needs on the order of n log n comparisons in the worst case. Merge sort and heapsort reach this bound.

Sorting without comparisons

Counting sort and radix sort order integers with a limited range or number of digits in near-linear time, without comparing elements to each other.

Where it is used

  • Ordering search results and leaderboards
  • Preprocessing for binary search and deduplication
  • Database ORDER BY and external sorting
  • Merging schedules and analyzing logs

Reference implementation

Merge sort implementation

merge_sort splits the list in half, sorts each half recursively, then merges the two sorted halves by repeatedly taking the smaller front element. Taking the left element on ties (<=) makes it stable, and it runs in O(n log n) for any input. The last line checks the result against the built-in sorted().

merge_sort.py

def merge_sort(items):
    """Return a new sorted list (stable, O(n log n))."""
    if len(items) <= 1:
        return list(items)
    mid = len(items) // 2
    left, right = merge_sort(items[:mid]), merge_sort(items[mid:])
    merged, i, j = [], 0, 0
    while i < len(left) and j < len(right):
        if left[i] <= right[j]:  # take the left one on ties: stable
            merged.append(left[i])
            i += 1
        else:
            merged.append(right[j])
            j += 1
    return merged + left[i:] + right[j:]


if __name__ == "__main__":
    data = [38, 27, 43, 3, 9, 82, 10]
    print(merge_sort(data))                  # [3, 9, 10, 27, 38, 43, 82]
    print(merge_sort(data) == sorted(data))  # True
python merge_sort.py

Step-by-step guide

Six chapters that take you from installation to the core ideas of Sorting.

  1. Sorting Concepts
  2. How It Works
  3. Implementation
  4. Complexity
  5. Practice Problems
  6. Real-World Use

Official docs and resources

  • OfficialSorting Techniques (Python HOWTO)
  • OfficialArrays (Java SE 21 & JDK 21 API)
  • LearnVisuAlgo: Sorting
  • LearnMIT 6.006 Introduction to Algorithms (Spring 2020)
  • ReferenceSorting algorithm (Wikipedia)
  • ReferenceCPython listsort.txt (Timsort design notes)
  • Referencestd::sort (cppreference.com)
  • ReferenceArray.prototype.sort() (MDN Web Docs)

Discussions

Start a discussion

Ask questions, share experience and trade opinions about Sorting.

No discussions yet. Start the first one.

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.