Fix sorting bug on branch dropdowns

b94151f231fe435f307badf8c5cfc488595c2681

Tucker McKnight | Wed Dec 31 2025

Fix sorting bug on branch dropdowns

Sort order wasn't being respected when tying in the
search box.

Also make it sort by date in reverse order -- that is, newest
(largest date number) on top.
frontend/main.js:107
Before
107
  dropdownBranchesResults.innerHTML = branchesListItems(branches, window.defaultBranch, window.currentBranch)
After
107
  dropdownBranchesResults.innerHTML = branchesListItems(branches, window.defaultBranch, window.currentBranch, sortDirection)
js_templates/common/branchesListItems.ts:5
Before
5
6
7
    if (a[sortBy] < b[sortBy]) { return -1 }
    if (a[sortBy] > b[sortBy]) { return 1 }
    return 0
After
5
6
7
    let comparison = 0
    if (a[sortBy] < b[sortBy]) { comparison = -1 }
    if (a[sortBy] > b[sortBy]) { comparison = 1 }
    // we want reverse order if sorting by date (making newest first)
    if (sortBy === 'date') { comparison = comparison * -1 }

    return comparison