Starting on the sorting algorithm
Ok so my plan here is to create some variables to start with.
Users to be matched - All registered users for the event
Number of Users Per Group - We will start with 4
Number of fields to check - We will start with all 5.
So first of all we make a copy of all users registered for this event.
Then we created a new array to hold everyone who is already grouped.
Then we set our group size variable and work out how many groups we will end up with.
lastly we make a new array to hold all the groups we will create.
 Great now we need to loop the amount of groups we need and start matching users.
ok so first we start a loop.
Then we make a new array to hold the group
Then we get the very first user in the registered array and remove them from the registered array (so we don’t grab them again)
We add them to the new group and then we add them to the usersgrouped array
Firstly we need a function that will compare 2 users.
This is a rudamentry function which will compare the stats of 2 users and return the sum of the absolute differences.
You can also see it takes a fields to match number, starting at 1 and ending at 5 (compare all stats)
Now the function that we use to compare each stat is very simple.
Great now that we have that lets sort the entire registered users array in order of how close they match to the first users. Ideally we want 0 (meaning all stats are equal)
Once we have sorted the list we will loop for however many users we need to add to the group.
Grab the first one and place it into the groups array.
and add the user to the usersgrouped array.
Then add that group to the array of groups.
Lastly we will log out some stats and then update our state.
That’s all for this post see ya next time when we start displaying the groups we matched.