Re: Setting a list to a random order
Re: Setting a list to a random order
- Subject: Re: Setting a list to a random order
- From: Michelle Steiner <email@hidden>
- Date: Mon, 23 May 2005 12:42:05 -0700
On May 23, 2005, at 12:23 PM, Steve Suranie wrote:
I have to read items from a file which are listed in a sequential
order and
randomize them - They appear in the file like this.
6510001460 1 14 $2 coupon
1410011417 2 14 $2 coupon
1210021412 3 14 $2 coupon
1910031454 4 14 $2 coupon
does anyone have a snippet of code that will shuffle a list?
set a to "6510001460 1 14 $2 coupon
1410011417 2 14 $2 coupon
1210021412 3 14 $2 coupon
1910031454 4 14 $2 coupon"
set b to paragraphs of a
set x to {}
set c to {}
repeat until (count of c) is (count of b)
set rnd to random number from 1 to count of b
if rnd is not in x then
copy item rnd of b to end of c
copy rnd to x
end if
end repeat
c
set text item delimiters to return
set d to c as text
set text item delimiters to ""
d
--
Windows was always a mystery to me; the biggest mystery being "Why
does anyone want to use this?"
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden