<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/array-sort-extensions-and-benchmarking-measuring-2d-and-jagged-array-optimized-sort-extensions-perf-womocamjc" -->

---
title: Array Sort Extensions and Benchmarking: Measuring 2D and...
description: Custom array sort extensions for C# are benchmarked against LINQ using BenchmarkDotNet on .NET 10.0. Tests cover 100 to 1,000,000 rows with 10 columns and...
canonical: https://daily.dev/posts/array-sort-extensions-and-benchmarking-measuring-2d-and-jagged-array-optimized-sort-extensions-perf-womocamjc
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Array Sort Extensions and Benchmarking: Measuring 2D and Jagged Array Optimized Sort Extensions Performance Against LINQ | daily.dev
og:description: Custom array sort extensions for C# are benchmarked against LINQ using BenchmarkDotNet on .NET 10.0. Tests cover 100 to 1,000,000 rows with 10 columns and...
og:url: https://daily.dev/posts/array-sort-extensions-and-benchmarking-measuring-2d-and-jagged-array-optimized-sort-extensions-perf-womocamjc
og:image: https://api.daily.dev/og/posts/woMocAmJc.png
og:image:alt: Array Sort Extensions and Benchmarking: Measuring 2D and Jagged Array Optimized Sort Extensions Performance Against LINQ
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Array Sort Extensions and Benchmarking: Measuring 2D and Jagged Array Optimized Sort Extensions Performance Against LINQ

**[C\# Corner](https://daily.dev/sources/csharpcorner)** · 20 min read · 0 upvotes · 0 comments

## Summary

Custom array sort extensions for C# are benchmarked against LINQ using BenchmarkDotNet on .NET 10.0. Tests cover 100 to 1,000,000 rows with 10 columns and 1024-byte cell payloads, comparing a 2D array QuickSort, a jagged array QuickSort, an IntroSort-based FastSort, and LINQ's OrderBy/ThenBy as baseline. Jagged_QuickSort reports zero heap allocations at every scale by swapping row references instead of copying cells. At 1,000,000 rows LINQ allocates about 100 MB while FastSort allocates just 88 bytes, with FastSort running about 13% slower than LINQ at that scale. The traditional 2D array (T[,]) shows higher execution times and greater memory allocations because sorting it means physically moving elements across columns.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.c-sharpcorner.com/article/array-sort-extensions-and-benchmarking-measuring-2d-and-jagged-array-optimized-sort-extensions-performance-against-linq>

## Questions this post answers

### Is sorting a jagged array (T[][]) faster than a rectangular 2D array (T[,]) in C#?

Yes, jagged arrays are significantly faster to sort because rows can be swapped by reference instead of copying individual cell elements. In a benchmark sorting 1,000,000 rows with 10 columns, the jagged array QuickSort ran in about 1.33 seconds compared to 4.23 seconds for the equivalent 2D array (T[,]) QuickSort, a roughly 3.37x difference, while also avoiding most heap allocations.

_Developers choosing between 2D and jagged arrays for large sorts can compare real benchmark numbers on daily.dev._

### How much memory does LINQ OrderBy/ThenBy allocate compared to a custom IntroSort implementation in C#?

At 1,000,000 rows with 10 columns, a LINQ OrderBy/ThenBy pipeline allocated over 95 MB (100,002,168 bytes), while a custom IntroSort implementation using Array.Sort with a zero-allocation struct comparer allocated only 88 bytes. Execution time for the custom sort stayed within about 13% of LINQ's mean time at that scale, according to BenchmarkDotNet results run on .NET 10.0.

_Anyone deciding between LINQ convenience and allocation-sensitive sorting can weigh these tradeoffs via daily.dev._

## Similar posts on daily.dev

- [Fast sorting, branchless by design](https://daily.dev/posts/fast-sorting-branchless-by-design-w7ar77tfp) · Lobsters · 0 upvotes · 0 comments
- [Pagination in EF Core, Continued: Sortable Grids, htmx, and the Indexing Cost - Chris Woody Woodruff](https://daily.dev/posts/pagination-in-ef-core-continued-sortable-grids-htmx-and-the-indexing-cost---chris-woody-woodruff-rqtvmyrpl) · We Are .NET · 1 upvotes · 0 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#performance](https://daily.dev/tags/performance), [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/array-sort-extensions-and-benchmarking-measuring-2d-and-jagged-array-optimized-sort-extensions-perf-womocamjc)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Array Sort Extensions and Benchmarking: Measuring 2D and Jagged Array Optimized Sort Extensions Performance Against LINQ","url":"https://daily.dev/posts/array-sort-extensions-and-benchmarking-measuring-2d-and-jagged-array-optimized-sort-extensions-perf-womocamjc","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/array-sort-extensions-and-benchmarking-measuring-2d-and-jagged-array-optimized-sort-extensions-perf-womocamjc"},"datePublished":"2026-10-25T13:56:59.820Z","dateModified":"2026-10-25T13:57:38.931Z","description":"Custom array sort extensions for C# are benchmarked against LINQ using BenchmarkDotNet on .NET 10.0. Tests cover 100 to 1,000,000 rows with 10 columns and...","image":"https://media.daily.dev/image/upload/s--58gMhC4P--/f_auto/v1722860399/public/Placeholder%2012","thumbnailUrl":"https://media.daily.dev/image/upload/s--58gMhC4P--/f_auto/v1722860399/public/Placeholder%2012","isAccessibleForFree":true,"articleSection":"C# Corner","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"C# Corner","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/ada2d584df6241748fc4e71878dc70a3","url":"https://daily.dev/sources/csharpcorner"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/array-sort-extensions-and-benchmarking-measuring-2d-and-jagged-array-optimized-sort-extensions-perf-womocamjc","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"general-programming,performance,.net,c#","timeRequired":"PT20M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"C# Corner","item":"https://daily.dev/sources/csharpcorner"},{"@type":"ListItem","position":3,"name":"Array Sort Extensions and Benchmarking: Measuring 2D and Jagged Array Optimized Sort Extensions Performance Against LINQ"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/array-sort-extensions-and-benchmarking-measuring-2d-and-jagged-array-optimized-sort-extensions-perf-womocamjc#faq","mainEntity":[{"@type":"Question","name":"Is sorting a jagged array (T[][]) faster than a rectangular 2D array (T[,]) in C#?","acceptedAnswer":{"@type":"Answer","text":"Yes, jagged arrays are significantly faster to sort because rows can be swapped by reference instead of copying individual cell elements. In a benchmark sorting 1,000,000 rows with 10 columns, the jagged array QuickSort ran in about 1.33 seconds compared to 4.23 seconds for the equivalent 2D array (T[,]) QuickSort, a roughly 3.37x difference, while also avoiding most heap allocations. Developers choosing between 2D and jagged arrays for large sorts can compare real benchmark numbers on daily.dev."}},{"@type":"Question","name":"How much memory does LINQ OrderBy/ThenBy allocate compared to a custom IntroSort implementation in C#?","acceptedAnswer":{"@type":"Answer","text":"At 1,000,000 rows with 10 columns, a LINQ OrderBy/ThenBy pipeline allocated over 95 MB (100,002,168 bytes), while a custom IntroSort implementation using Array.Sort with a zero-allocation struct comparer allocated only 88 bytes. Execution time for the custom sort stayed within about 13% of LINQ's mean time at that scale, according to BenchmarkDotNet results run on .NET 10.0. Anyone deciding between LINQ convenience and allocation-sensitive sorting can weigh these tradeoffs via daily.dev."}}]}
```

