X-Received: by 10.224.172.129 with SMTP id l1mr22261119qaz.4.1374250147069; Fri, 19 Jul 2013 09:09:07 -0700 (PDT) X-Received: by 10.49.118.232 with SMTP id kp8mr88065qeb.10.1374250147054; Fri, 19 Jul 2013 09:09:07 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!f1no41527qae.0!news-out.google.com!dk8ni705qab.0!nntp.google.com!f1no41519qae.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.forth Date: Fri, 19 Jul 2013 09:09:06 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=174.59.116.232; posting-account=6GCGIQoAAAAyO8IjR_VTwqiqLwx0Q_G8 NNTP-Posting-Host: 174.59.116.232 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Simple Sort - the smallest sorting routine? From: Brad Eckert Injection-Date: Fri, 19 Jul 2013 16:09:07 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.forth:24603 On Tuesday, June 25, 2013 4:12:55 PM UTC-4, The Beez wrote: > : sort > cells over + dup rot > ?do > dup i ?do i @ j @ precedes if i @ j @ i ! j ! then 1 cells +loop > 1 cells +loop > drop > ; After a bit of messing around, I hit upon the correct stack pictures. For those who aren't into solving puzzles to run code, this snippet is: defer precedes ' < is precedes : sort ( a n -- ) \ quick and dirty sort cells over + dup rot ?do dup i ?do i @ j @ precedes if i @ j @ i ! j ! then 1 cells +loop 1 cells +loop drop ;