Last active
September 8, 2020 15:26
-
-
Save nns2009/4a4bfe021d77057ce80a825d96a0c1ed to your computer and use it in GitHub Desktop.
Random Sort incorporates principles of security through obscurity to make your most sensitive pieces of code safe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Watch this video to see how I crafted this sorting algorithm: | |
// https://youtu.be/Mh_1V95n0j0 | |
function bDQnoAh__3IqiQ6w(MbK$rQXzgSJSupW) { | |
return Math.floor(Math.random() * MbK$rQXzgSJSupW); | |
} | |
function E68sk_VA6aM3y9ts1DO4S(xAAyxUzJedDW4t_) { | |
for (let SUiFIpIVdvQFCy = 1; SUiFIpIVdvQFCy < xAAyxUzJedDW4t_.length; SUiFIpIVdvQFCy++) { | |
if (xAAyxUzJedDW4t_[SUiFIpIVdvQFCy-1] > xAAyxUzJedDW4t_[SUiFIpIVdvQFCy]) | |
return false; | |
} | |
return true; | |
} | |
function GKdhrAZnKhQW6IsN5vc(qETVDGi1pAB7zDXu1) { | |
qETVDGi1pAB7zDXu1 = [...qETVDGi1pAB7zDXu1]; | |
while (!E68sk_VA6aM3y9ts1DO4S(qETVDGi1pAB7zDXu1)) { | |
const CUIfuNnK76Sne7ZMTM = bDQnoAh__3IqiQ6w(qETVDGi1pAB7zDXu1.length); | |
const TV$i4BvuUcFDOZT = bDQnoAh__3IqiQ6w(qETVDGi1pAB7zDXu1.length); | |
if ((CUIfuNnK76Sne7ZMTM < TV$i4BvuUcFDOZT) === | |
(qETVDGi1pAB7zDXu1[CUIfuNnK76Sne7ZMTM] < qETVDGi1pAB7zDXu1[TV$i4BvuUcFDOZT])) | |
continue; | |
const Pm9rKDnq6uXPl$45UHb = qETVDGi1pAB7zDXu1[CUIfuNnK76Sne7ZMTM]; | |
qETVDGi1pAB7zDXu1[CUIfuNnK76Sne7ZMTM] = qETVDGi1pAB7zDXu1[TV$i4BvuUcFDOZT]; | |
qETVDGi1pAB7zDXu1[TV$i4BvuUcFDOZT] = Pm9rKDnq6uXPl$45UHb; | |
} | |
return qETVDGi1pAB7zDXu1; | |
} | |
// Testing code | |
const AzVSbOSSehE72mzZigTvZWX = [34, 3, 13, 5, 8, 13, 21, 21, 55, 34, 3, 3, 2, 1, 34, 8]; | |
console.log(GKdhrAZnKhQW6IsN5vc(AzVSbOSSehE72mzZigTvZWX)); | |
console.log(AzVSbOSSehE72mzZigTvZWX.sort((wpuaeWEoVdgdCiFlHX3ae1, Bl$znCl98ap61kudtqxa) => wpuaeWEoVdgdCiFlHX3ae1 - Bl$znCl98ap61kudtqxa)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment