Merge pull request #938 from tidalcycles/pianoroll-sorting

fix: pianoroll sorting
This commit is contained in:
Felix Roos 2024-01-24 16:48:57 +01:00 committed by GitHub
commit dd64bf0fc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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!