Compares two tracks for sorting based on skip frequency

Custom comparison function for array sorting that prioritizes tracks by their recent skip count within the specified timeframe. Uses total skip count as a secondary sort criterion when recent counts are equal.

Designed for use with Array.sort() to order tracks by skip frequency.

export const sortBySkipCount = (
a: SkippedTrack,
b: SkippedTrack,
timeframeInDays: number,
): number => {
const recentSkipsA = getRecentSkipCount(a, timeframeInDays);
const recentSkipsB = getRecentSkipCount(b, timeframeInDays);

if (recentSkipsB !== recentSkipsA) {
return recentSkipsB - recentSkipsA;
}

return (b.skipCount || 0) - (a.skipCount || 0);
};