0

Setting up a self updating leaderboard for me and my friends, I opted to use a scraper+cronjob to feed .csv to an updating html table using this project.

https://github.com/derekeder/csv-to-html-table

I want to combine two columns data with their respective data to be more useful when sorted from ascending to decreasing.

Example input.csv

Name,Rank,LP,Wins,Losses,Winratio

name1,Gold 5,10 LP,7W,5L,Win Ratio 58%

name2,Platinum 1,100 LP,15W,13L,Win Ratio 54%

name3,Platinum 3,44 LP,9W,6L,Win Ratio 60%

name4,Diamond 3,41 LP,148W,147L,Win Ratio 50%

name5,Master,79 LP,121W,97L,Win Ratio 56%

Example output:Output

Now, what I'm looking to do is make the "Rank", "Wins" and "Losses" columns to sort by highest

These are the ranks Highest to Lowest, I don't think I can just match the exact name specifically since everything below Diamond gets separated into five separate sub categories by adding a number behind the rank, the only exclusions to this are Master and Challenger.

Trying this code didn't seem to do the job previously

case 'Challenger':    return 1;
case 'Master': return 2;
case 'Diamond':   return 3;
case 'Platinum':   return 4;
case 'Gold':   return 5;
case 'Silver':   return 6;
case 'Bronze':   return 7;

I was able to find documentation to resolve an issue similar to mine on the datatables website but I'm not proficient enough in jQuery to adapt it to my situation. https://www.datatables.net/examples/plug-ins/sorting_manual.html

4
  • We need a bit more information I think. Why didn't your switch work? It seems like it would help sort your ranks. Asuming you were removing the numbers and space after the ranks? Commented Mar 8, 2018 at 23:02
  • 1
    Can you post more code please Commented Mar 8, 2018 at 23:04
  • Post a snippet of the code you attempted for the sorting to get additional help. Commented Mar 8, 2018 at 23:16
  • Take a look at this: stackoverflow.com/questions/48886779/… and follow the link to the enum plugin - should do what you need. Commented Mar 9, 2018 at 17:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.