#How to make a list of all players sorted from closest to farthest
1 messages · Page 1 of 1 (latest)
Create two List<Player> Variable's, one called Unsorted Players, one called Sorted Players
You will need a loop for this to be instant, so lets use a For chip, and run from 0, to List Get Count, where the list in question is the players you want to sort from closest to furthest from X
Before running the For chip, set Unsorted Players to your player list (A copy of it if its from a variable or event), and set Sorted Players to a blank list, using a List Create with no inputs
When the loop is run, when Loop fires, get the closest person in Unsorted Players to your target, and add them to Sorted Players, after, remove that player from Unsorted Players
When Done fires, Sorted Players will return a list of all players in the initial list, sorted from closest to furthest
yeah I had this idea and tried it out but I may have done it worng, Ill give it another shot thanks
Remember that execution order matters, add them to Sorted Players BEFORE you remove them from Unsorted Players
yeah
Idk, I would use a get all players, then use (however many player count is) get element chips then I would use the same amount of get distance chips then I would shove those in another list
Then I would sort that list
So what your saying is you would rather do a hardcoded, unoptimized method that explodes your CPU, rather than doing my easier, optimized method?
Just because something uses a For Each doesnt mean its 100% CPU instantly
Does list sort have an execute
Sometimes you need to use a For chip
List Sort doesnt work on a player list
Also, instantly, your method is bad because its hard coded
You cant just get the element of every player, what if there is no player in that slot yet? you run into an index is out of range error
No you would get the index of the distances from smallest to largest
You are using more data then you have to for literally no reason
And take that from the original list
Give me a sec
if you send a screenshot I can assure you im going to vomit
works like a dream 
I would use List Remove At with the "Closest Index" output on the Get Closest chip, pretty sure its cheaper
changed it
I have just realised a possible flaw in this system, and I bring a solution
Delete the
Forchip, replace with aExecution Integer Switch, with the outputs0andFailed
Failed=Loop
0=Done
TheMatchshould be theList Get Countof theUnsortedlist variable
Connect the
List Remove Atexecution output back into theExecution Integer Switch
This should function in theory the exact same way, but better and without possible bugs
It basically continues until there are no more items in the list, rather than executing once for each item in the intial list
smart way to get arround that
huh?
Some random mind mapping map but this would be with two players, (otherwise you would just filter out the invalids)
I can't even call that unoptimized because I dont even think that works even remotely
Ik I didn’t go in more details but do you see what I think could work