• How can i sort names in alfabet order in my scoreboard?
    3 replies, posted
Hi. I'm making a scoreboard, but I'm pretty stuck at this moment, beacuse I can't find any guide on the internet to do this, so now I will ask you guys. How can i sort names in alfabet order in my scoreboard? The code I'm currently have to do this is:     for k, v in pairs(player.GetAll()) do         local row = self.ScrollPanel:Add('CAB_Scoreboard_Row')         row:SetPlayer(v)     end
https://www.youtube.com/watch?v=yRaOEXqqCEs https://www.youtube.com/watch?v=WbXMBs998rE found these after googeling "gmod scoreboard tutorial" for 2 seconds. the way you could sort by alphabet is creating a table, filling it with the 26 letters by order, and then iterating through your table that you want to order, checking if the word starts with A, and then you add that to a new list, when you iterated through the whole thing for A, go to the next with B and so on
Thats a method, but what if two players was named the same ex. John and Johna? What so? Isn't their a function for this?
im not aware of a alpahet sorting function in lua. If theres 2 names that sound similar, you just check for the second letter, which one comes first. and if thats the same, the third. and so on. at some point there will be a different letter, and the one that comes first in the alphabet is first in the order. Thats how alphabetic sorting works