A sorting technique that is used when the range of keys is relatively small and there are duplicate keys. Counting sorts differ from sorts that compare data in multiple passes. They work by creating an array of counters the size of the largest integer in the list; therefore, the keys must be integers or data that can be readily converted to integers.
In the first pass, each key value is used to index into the array to add 1. For example, if the key field contains 0000123, the 123rd counter in the array is incremented by 1.
**Counting Sort Vs. Rapid Sort**
Space equal to the original unordered list is allocated in memory, and the second pass of the counting sort scans the original list and uses the data in the counters to move each record from the original list into the sorted list.
A "rapid sort" is similar to a counting sort, except that it is used to only count the number of occurrences of key fields with no additional data. Instead of using the data in the counters to move records into a new sequence, the counter data in a rapid sort are used to print each key field along with its corresponding count. See sort algorithm.

# counting sort - Computer Definition

Computer Desktop Encyclopedia THIS DEFINITION IS FOR PERSONAL USE ONLY All other reproduction is strictly prohibited without permission from the publisher. © 1981-2017 The Computer Language Company Inc. All rights reserved.

Link to this page

Cite this page

**MLA Style**

"Counting sort."

*YourDictionary*. LoveToKnow. www.yourdictionary.com/counting-sort.**APA Style**

Counting sort. (n.d.). In

*YourDictionary*. Retrieved from https://www.yourdictionary.com/counting-sort