Double-Sort -
RedFusion - 09.02.2015
"Double-Sort"
Introduction
This is a basic sorting algorithm i wrote recently.
You can either sort the array by ascending or descending order.
Other Sorting Algorithms (In PAWN)
Sorting Algorithms (Wikipedia)
http://en.wikipedia.org/wiki/Sorting_algorithm
Test Script
removed since there are faster sorting algorithms out there.
Re: Double-Sort -
Kaperstone - 09.02.2015
How about more than 2 ?
Re: Double-Sort -
RedFusion - 09.02.2015
More than 2 of what?
Re: Double-Sort -
Kaperstone - 09.02.2015
Oh sorry, I thought its a sort by two arrays, because I didn't see a float(double) and the name hinted to one of the two.
So, its a regular sort (?)
Re: Double-Sort -
RedFusion - 09.02.2015
Yeah you got me confused for a while. Yes, it's a regular sort!
Respuesta: Double-Sort -
Swedky - 10.02.2015
eciN, but, can you give me some speed test? (I cant do it, because my PC dont work).
Re: Double-Sort -
codectile - 10.02.2015
There is already a sorting include for pawn in the CRF,
https://github.com/codectile/CRF-Lib...er/c_arlib.inc
Re: Double-Sort -
RedFusion - 10.02.2015
Quote:
Originally Posted by EnzoMetlc
eciN, but, can you give me some speed test? (I cant do it, because my PC dont work).
|
Sure, i'll provide speed tests on the main post in a short while.
Quote:
Originally Posted by ******
This looks like BubbleSort, which is a VERY slow sorting algorithm, and is recursive, which PAWN is not good at. Have you tried this on an array of, say 1000 unsorted elements? I'm pretty sure the server will run out of memory, after a long time. I suggest you read up on the algorithmic complexity of bubblesort vs quicksort.
|
Been re-writing it a few times and it should not resemble bubble-sort as much now.
And yes, i noticed it didn't work on arrays of bigger sizes (1000~ +), unfortunately....
I've been reading briefly about sorting algorithms but i haven't wrapped my head around what makes quicksort so much faster (yet).
Quote:
Originally Posted by codectile
|
CRF? Never heard of it before.
Re: Double-Sort -
codectile - 10.02.2015
Developing a fundamental algorithm for array sorting requires
excellent mathematics skills. Editing/re-inventing (as ****** said) algorithms can have a very bad impact on the results.
Re: Double-Sort -
RedFusion - 10.02.2015
Mainly because of educational purposes for me atleast, i like to learn things by re-inventing the wheel as you said. And ofcourse it's a positive thing if someone else reads my code and learns something from it.
I'm confident i'll be able to make a better sorting function in the future, once i have more knowledge on the subject.
And as i referred to more efficient sorting algorithms in the main post, then i really don't see what the problem is.
With that being said, i do understand your way of thinking aswell, making faster and more efficient code than those existing would be a bigger contribution.
Re: Double-Sort -
ipsLuan - 10.02.2015
Good Job!