Skip to content

Commit

Permalink
Merge pull request #938 from tidalcycles/pianoroll-sorting
Browse files Browse the repository at this point in the history
fix: pianoroll sorting
  • Loading branch information
felixroos authored Jan 24, 2024
2 parents 8fef753 + 434eb3b commit dd64bf0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/core/pianoroll.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,13 @@ export function pianoroll({
maxMidi = max;
valueExtent = maxMidi - minMidi + 1;
}
// foldValues = values.sort((a, b) => a - b);
foldValues = values.sort((a, b) => String(a).localeCompare(String(b)));
foldValues = values.sort((a, b) =>
typeof a === 'number' && typeof b === 'number'
? a - b
: typeof a === 'number'
? 1
: String(a).localeCompare(String(b)),
);
barThickness = fold ? valueAxis / foldValues.length : valueAxis / valueExtent;
ctx.fillStyle = background;
ctx.globalAlpha = 1; // reset!
Expand Down

0 comments on commit dd64bf0

Please sign in to comment.