From df1c97d7e6c85b8a6b91c9b946347ddf742e37c3 Mon Sep 17 00:00:00 2001 From: Gil Gonen Date: Mon, 8 Oct 2018 16:12:31 +0300 Subject: [PATCH] Fix tracks sorting in Offline tutorial sample code Sort bandwidths numerically instead of lexicographically. Fixes #1608 --- docs/tutorials/offline.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/offline.md b/docs/tutorials/offline.md index cbad21c023..878af3de20 100644 --- a/docs/tutorials/offline.md +++ b/docs/tutorials/offline.md @@ -135,9 +135,9 @@ function selectTracks(tracks) { // Store the highest bandwidth variant. var found = tracks .filter(function(track) { return track.type == 'variant'; }) - .sort(function(a, b) { return a.bandwidth > b.bandwidth; }) + .sort(function(a, b) { return a.bandwidth - b.bandwidth; }) .pop(); - console.log('Offline Track: ' + found); + console.log('Offline Track bandwidth: ' + found.bandwidth); return [ found ]; } @@ -487,9 +487,9 @@ function selectTracks(tracks) { // Store the highest bandwidth variant. var found = tracks .filter(function(track) { return track.type == 'variant'; }) - .sort(function(a, b) { return a.bandwidth > b.bandwidth; }) + .sort(function(a, b) { return a.bandwidth - b.bandwidth; }) .pop(); - console.log('Offline Track: ' + found); + console.log('Offline Track bandwidth: ' + found.bandwidth); return [ found ]; }