@7sage/vidstack
Version:
UI component library for building high-quality, accessible video and audio experiences on the web.
12 lines (10 loc) • 437 B
JavaScript
function sortVideoQualities(qualities, desc) {
return [...qualities].sort(desc ? compareVideoQualityDesc : compareVideoQualityAsc);
}
function compareVideoQualityAsc(a, b) {
return a.height === b.height ? (a.bitrate ?? 0) - (b.bitrate ?? 0) : a.height - b.height;
}
function compareVideoQualityDesc(a, b) {
return b.height === a.height ? (b.bitrate ?? 0) - (a.bitrate ?? 0) : b.height - a.height;
}
export { sortVideoQualities };