You can use a hash
function to create a pseudo-random ordering. An example is given using this hash function, but you can use any hash function you wish:
const hashCode = str => str.split('').reduce((prevHash, currVal) =>
(((prevHash << 5) - prevHash) + currVal.charCodeAt(0)) | 0, 0) % 100;
const data = ["a", "a", "c", "b", "bb", "car", "dog", "apple", "aaaaaple"];
const compare = (a, b) => hashCode(a) - hashCode(b);
data.sort(compare);
console.log(data);
This particular implementation will return
[ 'apple', 'bb', 'dog', 'car', 'aaaaaple', 'a', 'a', 'b', 'c' ]
every time.