Welcome to MacForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

number sort

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  Make Your iPad to Be A Blu –ray Movie Player  
Author Message
Jo_y

External


Since: Jan 23, 2010
Posts: 2



(Msg. 1) Posted: Fri Jun 18, 2010 10:38 am
Post subject: number sort
Archived from groups: alt>comp>lang>applescript (more info?)

i wrote a super-simple number sorter, but i want something more. how
to sort numbers with 5 digits like (4320,745,321)?


--only 1 digit!

set nr_ls to {3, 6, 3, 8, 1, 5}

set nw_ls to {}
repeat with i in nr_ls
set i to i as number
if nw_ls is {} then
copy i to end of nw_ls
else
set ref_of to last item of nw_ls
if i < ref_of then
copy i to end of nw_ls
else if i > ref_of then
copy i to beginning of nw_ls
end if
end if
end repeat
return nw_ls

 >> Stay informed about: number sort 
Back to top
Login to vote
JiPaul

External


Since: Jun 20, 2010
Posts: 1



(Msg. 2) Posted: Sun Jun 20, 2010 6:26 pm
Post subject: Re: number sort [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Michelle Steiner wrote:

> When I showed the listing to someone, he asked why I used a bubble sort,
> and I told him that I was sorting only 13 elements at a time, and there
> really wasn't any time advantage to a quicksort for so few elements.

Yes. It seems to me that Knuth (or Sedgewick, I'm not sure) recommends
to use insertion sort instead of quicksort when the number of elements
is small. And that the final part of quicksort (on small sets of number)
use actually insertion sort. But with bubble sort it's ok too :-)



--
JiPaul.
/ /--/--//\\ Jean-Paul Blanc
|/| L |\\\ quelquepart en (somewhere in)
\/|| = |||\\\ FRANCE

 >> Stay informed about: number sort 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Finder does not implement sort--workaround? - I was dismayed to view the Finder dictionary and find that the sort command has not yet been implemented. What is the standard workaround for this? -- Guns don't kill people; automobiles kill people.

Sort iTunes Playlist by location - Hello I don't have any knowledge about about applescript, and I am looking for a very small script.I would like to know how to sort the a playlist by location. I someone has an idea .... Thomas

sort a table: the real data rows are not sorted - I just learned how to sort a table based on a particular column (from Apple's example code Table Sort). The problem is, although the table appears to be sorted, the real data rows in the data source are not. If you try to get (item x of data source),..

Where are "ASCII number" and "ASCII character" documented? - Apple's website has some sample scripts that use "ASCII number" and "ASCII character". e.g.,: ASCII number "A" -- 65 Is this documented anywhere? (Ideally, I'd like to convert unicode to bytes without using extra applesc...

How to display the machine serial number ? - Hi, Do you know how to display the machine serial number ? (as displayed in the Apple System profiler) Thanks in advance -- Marc
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]