Created
July 2, 2025 07:12
-
-
Save trycf/c822b59ac8231c52cb6bdf18d486291f to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains hidden or 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
<cfscript> | |
/** | |
* Randomly shuffles an array of strings using Fisher-Yates algorithm. | |
* | |
* @param strings Array of strings to be shuffled | |
* @return Array of strings in random order | |
*/ | |
public array function shuffleArray(required array strings) localmode=true { | |
var shuffled = strings.clone(); // Clone to avoid mutating original array | |
var i = 0; | |
var j = 0; | |
var temp = ""; | |
for (i = shuffled.len(); i > 1; i--) { | |
j = randRange(1, i); // CFML arrays are 1-based | |
temp = shuffled[i]; | |
shuffled[i] = shuffled[j]; | |
shuffled[j] = temp; | |
} | |
return shuffled; | |
} | |
extrasIncudeFileNames = [ | |
"social-media-pack", | |
"shazam", | |
"audio-mack", | |
"beatport", | |
"store-maximizer", | |
"dolby", | |
"legacy" | |
]; | |
shuffledArray = shuffleArray(extrasIncudeFileNames); | |
writeDump(shuffledArray); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment