Jump to content


Photo

Data Sorting


  • Please log in to reply
8 replies to this topic

#1 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Elder
  • 7352 posts
  • Version:Unknown

Posted 04 March 2007 - 04:34 AM

Another quick extension from me. The data sorting methods provided in this extension allow you to sort both arrays and list data structures. So what does this offer over GM's built-in sorting method for lists? Well, one thing it provides is a way to specify a custom comparison function. This means you could, for example, store instance IDs in an array and then sort them according to the x value of each instance (or anything, really). The documentation gives a few examples of different things you can do with this.

This definitely isn't the final version I will make. There's a few speed optimizations I think I can make (at the cost of making some behind-the-scenes code longer and uglier, but that won't affect you, the user, outside of the speed gain). I will also consider other miscellaneous suggestions here (consider doesn't necessarily mean implement).

Download
  • 0

#2 JaketheSnake3636

JaketheSnake3636

    GMC Member

  • New Member
  • 1905 posts

Posted 06 March 2007 - 12:58 AM

Oh wow, this is awesome. I could REALLY have used this a couple weeks ago when making an online highscore system for my game. When using data structures there was no way to compare values and sort data easily and it made things pretty tedious. Nice job.

Edited by JaketheSnake3636, 06 March 2007 - 12:58 AM.

  • 0

#3 DMEISTER

DMEISTER

    GMC Member

  • GMC Member
  • 2692 posts

Posted 06 March 2007 - 11:10 AM

Would it work for any of these?

1. Soccer league table, sorting by points first and then goal difference?

2. Rally leaderboard, descending, can it sort by times or just real numbers?

3. Golf leaderboard, lowest score first (including negative values)

Thanks

DMEISTER
  • 0

#4 Yourself

Yourself

    The Ultimate Pronoun

  • GMC Elder
  • 7352 posts
  • Version:Unknown

Posted 06 March 2007 - 03:58 PM

With an appropriately written comparison function, it can sort anything.
  • 0

#5 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 07 March 2007 - 08:48 AM

OK I downloaded the extention.

I got a ds list with instances in it and would like to sort using the depth.

Can you tell me how to set it up?

Edited by icuurd12b42, 07 March 2007 - 08:48 AM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#6 Ansgar

Ansgar

    OM Studios

  • New Member
  • 333 posts

Posted 07 March 2007 - 01:19 PM

Why don't you read the extension's help file?

Anyway, thanks for another great extension from you, Yourself. I'll very likely soon find a use for it.

Edited by Ansgar, 07 March 2007 - 04:17 PM.

  • 0

#7 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 07 March 2007 - 01:57 PM

OK, it works now. I had a few parameters flipped and the wrong ds list data.

Cool stuff.

Edited by icuurd12b42, 07 March 2007 - 02:17 PM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#8 josheat

josheat

    GMC Member

  • New Member
  • 78 posts

Posted 21 March 2007 - 04:08 AM

This is great, thanks a lot!
  • 0

#9 JanOonk

JanOonk

    GMC Member

  • New Member
  • 8 posts

Posted 02 February 2012 - 09:41 PM

I could install the .gex in GM8.1 but I don't see any documentation: Help > Extension Packages > Data Sorting doesn't do anything.

Update: Well if you go to Resources > Select Extension Packages > Select Data Sorting in Available Packages > Click on Help button then it works.

So made a little test .gmk in GM7 Pro and GM8.1 Standard:
-created a object with on Create a little script:
test[0]=3;
test[1]=2;
test[2]=4;
test[3]=1;

sort("test",3,comp_ascending,sort_bubble);

but the sort function isn't recognized in both GM's?!

Edited by JanOonk, 02 February 2012 - 09:56 PM.

  • 0