SortM is a open-sourced module for sorting arrays (tables) in ROBLOX.
Hello, I am Oliver (or undiscvrd). I am a scripter here on ROBLOX, and while working on a script I found myself creating a extremely slow sorting algorithm. So, I decided to quickly make this module for easy sorting of tables/arrays.
I’ve only implemented 5 sorting algorithms, but I am open to adding more just request in the replies.
How to use the module?
To use the module you just simply import it using require require(Path.To.SortM) then access the Sort function.
local SortM = require(game:GetService("ReplicatedStorage").SortM)
local Array = {5,4,3,2,1}
local newArray = SortM.Sort(Array, "QuickSort")
print(tostring(newArray))
What sorting algorithms are there?
Quick Sort (QuickSort)
Insertion Sort (InsertionSort)
Selection Sort (SelectionSort)
Bubble Sort (BubbleSort)
Merge Sort (mergeSort)
What functions are included?
SortM.VerifyArray
SortM.Sort
SortM.AlgorithmList (Dictionary[Name:Function])
SortM is no longer available, however table.sort is a reliable option. Items in this course can also be referenced for learning sorting algorithms.
Hopefully it works well for yall, you like it. If you want to request something, or have an issue just send a reply down below. Also if I forgot to include something, feel free to tell me and I’ll include it.
I don’t know what sorting algorithm table.sort uses, but different algorithms can probably be of some use to some developers. That would probably be in some situations where you are dealing with gigantic tables and want something that is performant I guess
This is a nice way to improve coding skills but practically… lolmansReturn says it. table.sort() exists, its quite performant and overall quite beginner friendly
Radix sort would be my guess, I thought table.sort() used a “linear sorting algorithm”, but I cannot find that information on the docs (where I thought I saw it)