X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=roster.js;h=14f1cb46160b04f73e897ba2fa93b137f87d9783;hb=087accbb6caf2e3e2f42dcd92e7802a601de5503;hp=6a152a41853de2b956686cebc3d5723baccb4683;hpb=44bf264bc9045503216832dcc7261f885983df4c;p=ultimatescore diff --git a/roster.js b/roster.js index 6a152a4..14f1cb4 100644 --- a/roster.js +++ b/roster.js @@ -31,9 +31,19 @@ function load_roster(sheet, cb) "name": name }); } + roster.sort(function(a, b) { + let an = a['number']; + let bn = b['number']; + if (!(parseInt(an) > 0)) an = 1000; + if (!(parseInt(bn) > 0)) bn = 1000; + if (an !== bn) { + return an - bn; + } + return a['name'].localeCompare(b['name']); + }); cb(team_name, roster); }; - req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/18pTqrwSoqrb9_M9HJkiijMBAPppuSnFDAYEezZTKh00/values/\'' + sheet + '\'!A1:J50?key=AIzaSyAuP9yQn8g0bSay6r_RpGtpFeIbwprH1TU'); + req.open('GET', 'https://sheets.googleapis.com/v4/spreadsheets/' + ultimateconfig['roster_sheet_id'] + '/values/\'' + sheet + '\'!A1:J50?key=' + ultimateconfig['api_key']); req.send(); };