CodeBase - Quicksort Natural Sort Order

Return to the CodeBase listing

Category: Functions

Version: 1.0

0
0

Information

Uploaded: 29th Jun 2023 15:09

Modified: 29th Jun 2023 15:09

Author:  Ashingda 27

Summary

A method of using Quicksort to get a Natural sort order. Instead of getting "A10" sorted before "A5" you will get the correct sorting where the value of the numbers are taken into consideration.

Full Description

This is a simple and dirty way to achieve a Natural sort order.<br /> <br /> What is a Natural sort order? Normally when you sort with alphanumeric you will get incorrect ordering with numbers. Example: 1300 coming before 140<br /> <br /> Thus to solve this issue this method will pars through the original string array and creates a duplicate array but this one has all the numbers transformed so that they all have a digit of 6 (may be higher if desired) with ZEROs before the value of the number.<br /> Example:<br /> "Dave6" = "Dave000006"<br /> "001Doc80" = "000001Doc000080"<br /> "Joe20Danny999" = "Joe000020Danny000999"<br /> <br /> We now use QuickSort to sort out this modified array however the original array also gets sorted alongside it.

Comments

No comments yet.