Sorting algorithm
A sorting algorithm is a procedure that rearranges elements of a collection into an order determined by an ordering criterion.
Pandas Workout: 200 exercises to make you a stronger data analyst
Sorting orders tabular records according to the values of an index or one or more columns.
- How it is used
- Orders DataFrame rows and derived results for readable displays, rankings, and highest-or-lowest value queries.
- How deep it goes
- Distinguishes index and column ordering, then practices direction, multiple keys, and sorted aggregation outputs without algorithm internals.
- Examples
- Uses January 2019 NYC taxi rides and Stack Overflow survey salary summaries to practice ranked comparisons.
- What you can do after
- Apply it via pandas sort_values and sort_index to rank records, organize reports, and inspect grouped results.
MongoDB 8.0 in Action, Third Edition
Sorting is the ordering of query results according to one or more document fields.
- How it is used
- Orders MongoDB query results for presentation and navigation alongside skip and limit.
- How deep it goes
- Demonstrates sort directions and compound-index field order, but does not develop sorting-algorithm internals.
- Examples
- Shows routes ordered by stops and movies ordered by runtime and year, including a filtered movie query.
- What you can do after
- Apply it via MongoDB find().sort() and configure a matching compound index for multi-field ordering.
Read how MongoDB 8.0 in Action, Third Edition explains sorting algorithm →
Secrets of the JavaScript Ninja, Second Edition
An Array method that sorts an array in place using a comparison function or default ordering.
- How it is used
- Uses Array.sort() to order collections without implementing the sorting algorithm manually.
- How deep it goes
- Explains comparator return values and works through object sorting, but leaves the engine’s sorting algorithm behind the scenes.
- Examples
- Shows numeric subtraction as a comparator and sorts objects alphabetically by name with assertions checking their order.
- What you can do after
- Apply it via Array.sort() by writing a comparator for the desired item order.
Read how Secrets of the JavaScript Ninja, Second Edition explains sorting algorithm →
Python How-To
Sorting is the process of arranging elements into an order determined by a comparison or key function.
- How it is used
- Orders list items for display by a chosen property, such as task urgency.
- How deep it goes
- Explains default and key-based sorting through worked Python examples; does not develop a sorting algorithm’s internals.
- Examples
- Uses number and name lists, mixed-type comparison errors, urgency-ranked task dictionaries, and a description-length challenge.
- What you can do after
- Apply it via list.sort() or sorted() to order data with default comparisons or a custom key.
Python Workout, Second Edition
Sorting is the technique of arranging elements according to an ordering determined by their values or derived comparison keys.
- How it is used
- Applies ordering to nested Python data structures, especially lists of dictionaries prepared for display.
- How deep it goes
- Explains key functions, lambda, and itemgetter through exercises without descending into sorting algorithm internals.
- Examples
- Uses country dictionaries, string lengths, absolute values, vowel counts, nested-list sums, shell popularity, and multi-field movie records.
- What you can do after
- Builds country-sorting functions with named keys, lambdas, and operator.itemgetter.
Read how Python Workout, Second Edition explains sorting algorithm →
Tiny Python Projects: Learn coding and testing with puzzles and games
Sorting is the operation of arranging collection elements according to an ordering criterion.
- How it is used
- Deploys sorting to order command-line list data and to make randomized-program tests reproducible.
- How deep it goes
- Explains in-place and returned-list operations, reverse ordering, numeric behavior, and mixed-type errors, but not sorting algorithms internally.
- Examples
- Demonstrates sorted picnic output, REPL lists, descending order, numeric values, mixed-type failure, and sorted password words.
- What you can do after
- Apply it via Python list.sort() or sorted() to order data while choosing whether to mutate or preserve the original.
Building Web APIs with ASP.NET Core
Sorting is the ordering of query results according to one or more specified fields or expressions.
- How it is used
- Improves board-game API responses by ordering records before returning configurable result pages.
- How deep it goes
- Explains database versus in-memory sorting, OrderBy limitations, dynamic strings, package installation, and endpoint integration.
- Examples
- Uses board-game JSON results, OrderBy(b => b.Name), dynamic sortColumn and sortOrder parameters, and paged controller queries.
- What you can do after
- Apply it via EF Core and System.Linq.Dynamic.Core to build database-backed, client-configurable sorting for API endpoints.
Read how Building Web APIs with ASP.NET Core explains sorting algorithm →
Python Workout: 50 ten-minute exercises
Sorting is the technique of arranging elements according to an ordering determined by their values or derived comparison keys.
- How it is used
- Uses sorting to organize Python data structures and solve exercises involving derived ordering criteria.
- How deep it goes
- Explains sorted and key-based ordering, but stops short of algorithm internals or implementation details.
- Examples
- Uses absolute values, vowel counts, nested-list sums, repeated vowels, and Unix shell popularity as sorting criteria.
- What you can do after
- Apply it via Python’s sorted function and key parameter to order data by custom properties.
Read how Python Workout: 50 ten-minute exercises explains sorting algorithm →
The Quick Python Book, Fourth Edition
- How it is used
- Orders lists and file rows to support summaries, duplicate handling, and grouping related records.
- How deep it goes
- Explains in-place and copied sorting, comparison rules, keys, memory trade-offs, and file-size alternatives; stops short of algorithm internals.
- Examples
- Uses numbers, strings, nested lists, temperature records, and text-file rows as sorting examples.
- What you can do after
- Apply it via Python’s list.sort(), sorted(), or UNIX sort to order collections and file rows.
Read how The Quick Python Book, Fourth Edition explains sorting algorithm →
The Design of Web APIs, Second Edition
Sorting is the technique of ordering returned items according to one or more specified fields and directions.
- How it is used
- Supports flexible list and search operations by ordering results for browsing, rendering, processing, and targeted retrieval.
- How deep it goes
- Defines single- and multi-field ordering, defaults, consistency, and schema documentation, while deferring broader design alternatives to contextual choice.
- Examples
- Uses bank-account transactions, amount and date ordering, balance searches, and documented ordering for balance arrays.
- What you can do after
- Apply it via query parameters to design consistent, optionally sorted list and search operations with useful defaults.
Read how The Design of Web APIs, Second Edition explains sorting algorithm →
Clojure: The Essential Reference
The arrangement of elements into an order determined by a comparison criterion.
- How it is used
- Orders collection elements by their natural comparison or a supplied comparator.
- How deep it goes
- Defines input, comparator, output, and notable exceptions, but does not detail the sorting algorithm's internals.
- Examples
- Demonstrates sorting keywords, numbers, maps by age, and mixed values by string conversion.
- What you can do after
- Apply sort or sort-by with a comparator or key function to produce an ordered sequence.
Read how Clojure: The Essential Reference explains sorting algorithm →
Java Persistence with Spring Data and Hibernate epub
Sorting is the ordering of query results according to one or more attributes.
- How it is used
- Applies ordering while limiting repository results or dividing large result sets into pages.
- How deep it goes
- Defines derived method names, Sort, Pageable, and PageRequest usage, but does not detail generated query internals.
- Examples
- Uses username and registration-date ordering, level-filtered users, Sort.by, PageRequest.of, Optional<User>, and Page<User>.
- What you can do after
- Apply it via Spring Data repository methods to retrieve ordered, limited, or paginated users.
Read how Java Persistence with Spring Data and Hibernate epub explains sorting algorithm →
D3.js in Action, Third Edition
sort() is the JavaScript Array method that orders array elements according to an optional comparison function.
- How it is used
- Prepares measured datasets for readable bar-chart visualizations.
- How deep it goes
- Demonstrates a comparison function and its placement in a data-processing workflow, without detailing broader sorting mechanics.
- Examples
- Uses a technologies dataset ordered by count, including Excel, Tableau, and Angular.
- What you can do after
- Apply via JavaScript sort() to order records by a numeric field before building a visualization.
Read how D3.js in Action, Third Edition explains sorting algorithm →
Grokking Algorithms, Second Edition
A sorting algorithm is an algorithm that arranges elements according to an ordering criterion.
- How it is used
- Introduces selection sort as a first sorting algorithm and a stepping stone to quicksort.
- How deep it goes
- Positions selection sort as preparation for quicksort, without detailing its procedure in this coverage.
- Examples
- Uses an alphabetized phone book to illustrate how sorted data supports binary search.
- What you can do after
- Understand how sorted data enables binary search and why selection sort prepares readers for quicksort.
Read how Grokking Algorithms, Second Edition explains sorting algorithm →
Learn SQL in a Month of Lunches
Result ordering is the specification of the sequence in which rows are returned by a query.
- How it is used
- Uses explicit query ordering to make result sequences predictable, readable, and useful for selecting recent or extreme values.
- How deep it goes
- Explains why implicit order is unreliable and motivates explicit sorting, but does not show sorting syntax or execution internals.
- Examples
- Uses library authors, building floors, calendars, title listings, recent entries, and alphabetizing titles while ignoring articles.
- What you can do after
- Practice/perform it by writing queries whose results follow a required alphabetical, date-based, or value-based sequence.
Read how Learn SQL in a Month of Lunches explains sorting algorithm →
100 SQL Server Mistakes and How to Avoid Them
A sort operation arranges rows according to specified ordering keys during query execution or index maintenance.
- How it is used
- Treats sorting as a presentation choice to apply only when ordered output is genuinely required.
- How deep it goes
- Explains sort operators, estimated plan costs, timing tests, and inaccurate statistics, but does not develop sorting internals.
- Examples
- Uses CustomerContacts queries ordered by email, execution-plan figures, timing output, and a covering-index definition.
- What you can do after
- Diagnose sorting overhead by comparing T-SQL timings and inspecting plans in SQL Server Management Studio.
Read how 100 SQL Server Mistakes and How to Avoid Them explains sorting algorithm →
Learn Go with Pocket-Sized Projects
Sorting is the technique of ordering elements in a collection according to a specified comparison criterion.
- How it is used
- Uses sorting to produce deterministic collection results that are easier to test and consume.
- How deep it goes
- Explains custom comparators, multi-field ordering, slice mutation, and string-encoding limitations, but defers deeper sort details.
- Examples
- Uses books sorted by author then title and habits sorted by creation time.
- What you can do after
- Apply it via Go’s sort.Slice to order slices deterministically with custom comparison logic.
Read how Learn Go with Pocket-Sized Projects explains sorting algorithm →
Build a Website with ChatGPT
Sorting is the operation of arranging data records or values according to an ordering criterion.
- How it is used
- Deploys sorting as a course-catalog control alongside filtering and searching.
- How deep it goes
- Explains the control-to-redisplay workflow but stops short of algorithm internals or detailed sorting code.
- Examples
- Uses a course catalog whose records sort by Department or Title through a drop-down list.
- What you can do after
- Apply it via JavaScript by connecting a sort selector to reordered JSON records and a refreshed article element.
Read how Build a Website with ChatGPT explains sorting algorithm →
Related concepts
- quicksortincludes · Quicksort is a comparison-based sorting algorithm that partitions elements around a pivot and recursively sorts the resulting subranges.
- heapsortincludes · Heapsort is a comparison-sorting algorithm that uses a heap to repeatedly select elements and produce an ordered sequence.
- shufflecontrasts with · Shuffling is the random rearrangement of elements in a collection, sequence, or dataset.
- listuses · A list is an ordered collection of elements arranged in a sequence.
- comparison functionuses · A comparison function or strategy compares two values and indicates their relative ordering, and sometimes whether they are equivalent.
- sortedcontrasts with · sorted is a Python built-in function that returns a new list containing an iterable’s elements in sorted order without modifying the original iterable.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

















