The Daily Click ::. Forums ::. Klik Coding Help ::. Sorting values the proper way?
 

Post Reply  Post Oekaki 
 

Posted By Message

Zephni

My other cars a Balrog

Registered
  17/10/2007
Points
  4019

Has Donated, Thank You!VIP MemberSonic Speed
8th December, 2009 at 18:04:18 -

Hey guys, i know we have the 'sort X' object, but how about doing the same thing with just useing fastloops.
I'd like to know 1. So i know how to do it the proper way and 2. So i don't have to use any premade objects in my game.

By sorting i meen:
1: 5 --> 1: 1
2: 1 --> 2: 3
3: 8 --> 3: 5
4: 3 --> 4: 8

and where the AMOUNT of index's are variable.
I guess its done with a loop (in this case) that would loop 4 times, and on that loop fire up another loop the loops 4 times to find the highest one, and takes that one out of the list and adds it to the SORT list.
But ignore me, just tell me how you know its done.

Thanks much appreciated

 
dont make me divide by zero...

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
10th December, 2009 at 04:00:00 -

There's lots of sorting algorithms. I only know bubble sort. It's pretty much the easiest to understand and implement.
See wikipedia http://en.wikipedia.org/wiki/Sorting_algorithm

 
This space is for rent

cake



Registered
  13/12/2002
Points
  1173
14th December, 2009 at 05:15:14 -

Honestly I don't think Events are a very good way to sort things. Sorting algorithms typically have a reasonably involved combination of loops and conditions. It's too much of a pain when you can just add everything to a list and use the list's sorting functionality.

If you want to learn sorting algorithms, I strongly recommend an actual script-based programming language like C or Java.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click