Monday, January 7, 2019

Sorting Algorithm

As the name implies, its sort the value in the array from the smallest number to the largest number.

Currently the best sorting algorithm for sorting integer is counting sort.

Snippet

Note : This sort from the smallest value to the largest value
to sort from largest to smallest value, simply change .@out[.@size -1] into .@out[.@total - .@size]


I have used in
1. Reward to the guild captured most flags, or have highest score (outdated - still using comb-sort)
2. Reward to the players kill the most monsters (script)


And the best sorting algorithm to sort strings is comb sort.

Snippet

This one sort the string alphabetically, A-Z

I have use in ....
NONE
I prepared this function, but never find any chance to use it
because most of the time when needed to sort alphabets, it was done in SQL, in a large table




External Links:

Merge sort algorithm improvement - Credit to Keyworld and Haru for helping me ~
meko's Array manipulation functions

See also:

Shuffle algorithm

No comments:

Post a Comment

Linux compiler error that never shown on Visual Studio

let's just admit Visual Studio sux ... ok ? right now, if you want to host a Private Ragnarok Online server, its just better to choose...