Skip to content

Commit

Permalink
fix comparator for phetsims/scenery#1282
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Feb 7, 2022
1 parent 04f907b commit 289885f
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions js/accessibility/voicing/voicingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,11 @@ class VoicingManager extends Announcer {
assert && assert( this.voices.length > 0, 'No voices available to provided a prioritized list.' );

return this.voices.slice().sort( ( a, b ) => {
if ( a.name.includes( 'Fred' ) ) {

// if a includes 'Fred' then but b before a so 'Fred' is at the bottom
return 1;
}
else {

// a before b so 'Google' voices are at the top, otherwise voices are considered equal
return a.name.includes( 'Google' ) ? -1 : 0;
}
return a.name.includes( 'Fred' ) ? 1 : // a includes 'Fred', put b before a so 'Fred' is at the bottom
b.name.includes( 'Fred' ) ? -1 : // b includes 'Fred', but a before b so 'Fred' is at the bottom
a.name.includes( 'Google' ) ? -1 : // a includes 'Google', put a before b so 'Google' is at the top
b.name.includes( 'Google' ) ? 1 : // b includes 'Google, 'put b before a so 'Google' is at the top
0; // otherwise all voices are considered equal
} );
}

Expand Down

0 comments on commit 289885f

Please sign in to comment.