Create random list in ColdFusion (Randomizer)

February 12, 2008 at 7:21 am 1 comment

Looking for a way to generate a random list of values in ColdFusion?

The following code generates a random list from myList and puts the random values in myNewList.

            myList = “1,2,3”;
            myNewList = “”;
            listLength = listLen( myList );
            while( listLength neq 0 ) {
                        myIndex = randRange( 1, listLength );
                        myItem = listGetAt( myList, myIndex );
                        myNewList = listAppend( myNewList, myItem );
                        myList = listDeleteAt( myList, myIndex );
  listLength = listLen( myList );

I’ve kept the demo simple and only had 3 items in the list (myList = “1,2,3”) obviously you could use this with a much bigger list.

I have not benchmarked any of this, so I can’t say how it would hold up with a very large list. Any comments to improve are welcome, or if you have bench marked this, let us know 😉


Entry filed under: ColdFusion. Tags: , .

Introducing Rob from JustWeb clickfind is on

1 Comment Add your own

  • 1. Bob Beecher  |  September 7, 2013 at 2:04 pm

    So much simpler than others I looked at. I love it.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 20 other followers


Top Rated

Top Clicks

  • None

Blog Stats

  • 170,012 hits

%d bloggers like this: