Multiset Equivalence Problem | JavaScript program to check if two given multisets are equivalent ; sort the elements of both multisets ; Return true if both multisets are same . ; Driver code
function areSame ( a , b ) { a . sort ( ( a , b ) => a - b ) ; b . sort ( ( a , b ) => a - b ) ; return ( a == b ) ; } let a = [ 7 , 7 , 5 ] , b = [ 7 , 5 , 5 ] ; if ( areSame ( a , b ) ) document . write ( " " ) ; else document . write ( " " ) ;