generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: table.sort

Previous Thread :: Next Thread 
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
15 Nov 2016 11:21 PM
This is a code problem but roblox is giving me bad requests so I kinda have to do this.

goo.gl/0NTZ4h


Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
15 Nov 2016 11:28 PM
What is the expected set, and the input set?
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
15 Nov 2016 11:33 PM
an array of gui elements is the input. basically getChildren() but on all levels of the ########## the expected output is to have the element with the higher absolutePosition.X and Y to be t[1] and the ones with the lowest of both will be ###### ## ## only returning t[1] (and t[2]?) correctly. But I am using t[3] in parts. of my code.
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
15 Nov 2016 11:38 PM
So t[1] is the subset of higher absolute positions, while t[2] is the subset of lower absolute positions? Is t[3] that of the same? The # really didn't help understanding.
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
15 Nov 2016 11:46 PM
everytime I have a long post it gives me bad request error.

goo.gl/T5Rk3C


Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
15 Nov 2016 11:57 PM
"The sort algorithm is not stable; that is, elements considered equal by the given order may have their relative positions changed by the sort. " - Roblox wiki

Not sure if this is what's happening, but I would use a custom selection sort. Not too difficult to achieve, and you know that you are getting exactly what you want. I looked at your function and nothing seemed to cause an issue (though I only tested it on paper, so I may have made a human error). I'm assuming this isn't going to update frequently? If so I would do a merge sort. Fastest big-o value of, don't quote me, 1 I believe.
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
16 Nov 2016 12:00 AM
Correction on the big-o it's O(nlog(n))
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
16 Nov 2016 12:01 AM
I was trying to make a custom sort but I can't think of a way on how.
Psuedocode?


Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
16 Nov 2016 12:09 AM
Alright, give me a few. Sorting algorithm's can be kinda difficult to think up on the spot.
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
16 Nov 2016 12:24 AM
##################### See if that helps, it's a basic selection sort. I couldn't remember if editing a table in a function made changes to the original, so I just copied the data to a new table.
Report Abuse
Riderj is not online. Riderj
Joined: 15 Aug 2011
Total Posts: 1534
16 Nov 2016 12:25 AM
goo.gl/UEIxUM
Report Abuse
newcoolman2 is not online. newcoolman2
Joined: 01 Apr 2010
Total Posts: 2637
16 Nov 2016 07:03 PM
I was using table.sort wrongly

I was looking to do something like this. New day clear head. :)


local function sortedFrames()
local t=getDescendants(chatFrame)
sort(t,function(a,b)
return(a.AbsolutePosition.Y--[[roblox filter]]>b.AbsolutePosition.Y)
end)
for i=1,#t,1 do
if i%2==1 then
if t[i].AbsolutePosition.X<--[[]]t[i+1].AbsolutePosition.X then
t[i],t[i+1]=t[i+1],t[i]
end
end
end
return t
end


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image