|
| 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
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 15 Nov 2016 11:28 PM |
| What is the expected set, and the input set? |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 15 Nov 2016 11:46 PM |
everytime I have a long post it gives me bad request error.
goo.gl/T5Rk3C
|
|
|
| Report Abuse |
|
|
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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
| |
|
|
| 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 |
|
|