[Jprogramming] sorting up and up
Henry Rich
henryhrich at gmail.com
Fri Oct 22 11:04:39 UTC 2021
Offset binary.
/:~&.(22 b.&16b8000000000000000)
Entered from my phone & untested.
Henry Rich
On Fri, Oct 22, 2021, 12:59 PM Jan-Pieter Jacobs <janpieter.jacobs at gmail.com>
wrote:
> I would do:
>
> (/: 0&>)@/:~ i: 10
>
> which makes use of sort being stable.
>
> On Fri, Oct 22, 2021, 12:20 ethiejiesa via Programming <
> programming at jsoftware.com> wrote:
>
> > Sort and rotate?
> >
> > (|.~ +/@:<&0)@(/:~) _10+10?.@$20
> > 4 6 6 6 9 _5 _4 _4 _2 _2
> >
> >
> > Elijah Stone <elronnd at elronnd.net> wrote:
> > > This is not terrible, though the >: rankles:
> > >
> > > (/: ] + 0&> * [: >: >./ - <./) i: 10
> > > 0 1 2 3 4 5 6 7 8 9 10 _10 _9 _8 _7 _6 _5 _4 _3 _2 _1
> > >
> > > I am sure somebody else has a prettier solution.
> > >
> > > -E
> > >
> > > On Fri, 22 Oct 2021, R.E. Boss wrote:
> > >
> > > > Some time ago I stumbled on an elegant solution to sort a sequence of
> > numbers such, that first the non-negative numbers were sorted up,
> > immediately followed by the negative numbers sorted up, like
> > > >
> > > > foo i: 10
> > > > 0 1 2 3 4 5 6 7 8 9 10 _10 _9 _8 _7 _6 _5 _4 _3 _2 _1
> > > >
> > > > Any takers?
> > > >
> > > >
> > > > R.E. Boss
> > > >
> ----------------------------------------------------------------------
> > > > For information about J forums see
> http://www.jsoftware.com/forums.htm
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
More information about the Programming
mailing list