Arrow those variables!












11












$begingroup$


Challenge



Robin likes having his variables declaration in the shape of an arrow. Here's how he does it:




  • Input any number of strings

  • Order them by ascending length


  • Output them ordered by the middle to roughly form a negative arrowhead, like this (whichever order golfs the best):



    5  or  4
    3 2
    1 1
    2 3
    4 5



Test Cases



Input:



bow
arrows
sheriffOfNottingham
kingRichard
maidMarian
princeJohn
sherwoodForest


Output:



sheriffOfNottingham
kingRichard
maidMarian
bow
arrows
princeJohn
sherwoodForest


Input:



a
bb
cc


Output (both are valid):



bb
a
cc

cc
a
bb


Input:



one
four
seven
fifteen


Possible output (the only other valid output is its vertical mirror):



seven
one
four
fifteen


Notes




  • The strings are in camelCase and have no numbers or special characters, only lowercase and uppercase letters.


  • The input can be anything you like: comma-separated as one string, array, ... Any I/O format is allowed.


  • Between strings with the same length, any order is accepted.










share|improve this question









New contributor




Teleporting Goat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $begingroup$
    I feel like there was a very similar challenge before...but welcome to PPCG!
    $endgroup$
    – Giuseppe
    12 hours ago












  • $begingroup$
    @Giuseppe Yeah that's what I thought after posting, there's no way it hasn't been done before. Would you be ok with me deleting it now that you've answered it?
    $endgroup$
    – Teleporting Goat
    12 hours ago












  • $begingroup$
    well I've been searching for a dupe but I'm not very good at the search...we do have a sandbox for posting challenges which can often catch things like that. I'm perfectly OK with you deleting it if you're worried about it being a dupe.
    $endgroup$
    – Giuseppe
    12 hours ago












  • $begingroup$
    @Giuseppe Well it's too late, with 2 answers SE won't let me delete it. I had hoped for a better start in PPCG...
    $endgroup$
    – Teleporting Goat
    12 hours ago








  • 1




    $begingroup$
    Could you add a test case with an even number of strings?
    $endgroup$
    – Sherlock9
    12 hours ago
















11












$begingroup$


Challenge



Robin likes having his variables declaration in the shape of an arrow. Here's how he does it:




  • Input any number of strings

  • Order them by ascending length


  • Output them ordered by the middle to roughly form a negative arrowhead, like this (whichever order golfs the best):



    5  or  4
    3 2
    1 1
    2 3
    4 5



Test Cases



Input:



bow
arrows
sheriffOfNottingham
kingRichard
maidMarian
princeJohn
sherwoodForest


Output:



sheriffOfNottingham
kingRichard
maidMarian
bow
arrows
princeJohn
sherwoodForest


Input:



a
bb
cc


Output (both are valid):



bb
a
cc

cc
a
bb


Input:



one
four
seven
fifteen


Possible output (the only other valid output is its vertical mirror):



seven
one
four
fifteen


Notes




  • The strings are in camelCase and have no numbers or special characters, only lowercase and uppercase letters.


  • The input can be anything you like: comma-separated as one string, array, ... Any I/O format is allowed.


  • Between strings with the same length, any order is accepted.










share|improve this question









New contributor




Teleporting Goat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$












  • $begingroup$
    I feel like there was a very similar challenge before...but welcome to PPCG!
    $endgroup$
    – Giuseppe
    12 hours ago












  • $begingroup$
    @Giuseppe Yeah that's what I thought after posting, there's no way it hasn't been done before. Would you be ok with me deleting it now that you've answered it?
    $endgroup$
    – Teleporting Goat
    12 hours ago












  • $begingroup$
    well I've been searching for a dupe but I'm not very good at the search...we do have a sandbox for posting challenges which can often catch things like that. I'm perfectly OK with you deleting it if you're worried about it being a dupe.
    $endgroup$
    – Giuseppe
    12 hours ago












  • $begingroup$
    @Giuseppe Well it's too late, with 2 answers SE won't let me delete it. I had hoped for a better start in PPCG...
    $endgroup$
    – Teleporting Goat
    12 hours ago








  • 1




    $begingroup$
    Could you add a test case with an even number of strings?
    $endgroup$
    – Sherlock9
    12 hours ago














11












11








11


1



$begingroup$


Challenge



Robin likes having his variables declaration in the shape of an arrow. Here's how he does it:




  • Input any number of strings

  • Order them by ascending length


  • Output them ordered by the middle to roughly form a negative arrowhead, like this (whichever order golfs the best):



    5  or  4
    3 2
    1 1
    2 3
    4 5



Test Cases



Input:



bow
arrows
sheriffOfNottingham
kingRichard
maidMarian
princeJohn
sherwoodForest


Output:



sheriffOfNottingham
kingRichard
maidMarian
bow
arrows
princeJohn
sherwoodForest


Input:



a
bb
cc


Output (both are valid):



bb
a
cc

cc
a
bb


Input:



one
four
seven
fifteen


Possible output (the only other valid output is its vertical mirror):



seven
one
four
fifteen


Notes




  • The strings are in camelCase and have no numbers or special characters, only lowercase and uppercase letters.


  • The input can be anything you like: comma-separated as one string, array, ... Any I/O format is allowed.


  • Between strings with the same length, any order is accepted.










share|improve this question









New contributor




Teleporting Goat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




Challenge



Robin likes having his variables declaration in the shape of an arrow. Here's how he does it:




  • Input any number of strings

  • Order them by ascending length


  • Output them ordered by the middle to roughly form a negative arrowhead, like this (whichever order golfs the best):



    5  or  4
    3 2
    1 1
    2 3
    4 5



Test Cases



Input:



bow
arrows
sheriffOfNottingham
kingRichard
maidMarian
princeJohn
sherwoodForest


Output:



sheriffOfNottingham
kingRichard
maidMarian
bow
arrows
princeJohn
sherwoodForest


Input:



a
bb
cc


Output (both are valid):



bb
a
cc

cc
a
bb


Input:



one
four
seven
fifteen


Possible output (the only other valid output is its vertical mirror):



seven
one
four
fifteen


Notes




  • The strings are in camelCase and have no numbers or special characters, only lowercase and uppercase letters.


  • The input can be anything you like: comma-separated as one string, array, ... Any I/O format is allowed.


  • Between strings with the same length, any order is accepted.







code-golf string sorting






share|improve this question









New contributor




Teleporting Goat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Teleporting Goat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 12 hours ago







Teleporting Goat













New contributor




Teleporting Goat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 13 hours ago









Teleporting GoatTeleporting Goat

1564




1564




New contributor




Teleporting Goat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Teleporting Goat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Teleporting Goat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • $begingroup$
    I feel like there was a very similar challenge before...but welcome to PPCG!
    $endgroup$
    – Giuseppe
    12 hours ago












  • $begingroup$
    @Giuseppe Yeah that's what I thought after posting, there's no way it hasn't been done before. Would you be ok with me deleting it now that you've answered it?
    $endgroup$
    – Teleporting Goat
    12 hours ago












  • $begingroup$
    well I've been searching for a dupe but I'm not very good at the search...we do have a sandbox for posting challenges which can often catch things like that. I'm perfectly OK with you deleting it if you're worried about it being a dupe.
    $endgroup$
    – Giuseppe
    12 hours ago












  • $begingroup$
    @Giuseppe Well it's too late, with 2 answers SE won't let me delete it. I had hoped for a better start in PPCG...
    $endgroup$
    – Teleporting Goat
    12 hours ago








  • 1




    $begingroup$
    Could you add a test case with an even number of strings?
    $endgroup$
    – Sherlock9
    12 hours ago


















  • $begingroup$
    I feel like there was a very similar challenge before...but welcome to PPCG!
    $endgroup$
    – Giuseppe
    12 hours ago












  • $begingroup$
    @Giuseppe Yeah that's what I thought after posting, there's no way it hasn't been done before. Would you be ok with me deleting it now that you've answered it?
    $endgroup$
    – Teleporting Goat
    12 hours ago












  • $begingroup$
    well I've been searching for a dupe but I'm not very good at the search...we do have a sandbox for posting challenges which can often catch things like that. I'm perfectly OK with you deleting it if you're worried about it being a dupe.
    $endgroup$
    – Giuseppe
    12 hours ago












  • $begingroup$
    @Giuseppe Well it's too late, with 2 answers SE won't let me delete it. I had hoped for a better start in PPCG...
    $endgroup$
    – Teleporting Goat
    12 hours ago








  • 1




    $begingroup$
    Could you add a test case with an even number of strings?
    $endgroup$
    – Sherlock9
    12 hours ago
















$begingroup$
I feel like there was a very similar challenge before...but welcome to PPCG!
$endgroup$
– Giuseppe
12 hours ago






$begingroup$
I feel like there was a very similar challenge before...but welcome to PPCG!
$endgroup$
– Giuseppe
12 hours ago














$begingroup$
@Giuseppe Yeah that's what I thought after posting, there's no way it hasn't been done before. Would you be ok with me deleting it now that you've answered it?
$endgroup$
– Teleporting Goat
12 hours ago






$begingroup$
@Giuseppe Yeah that's what I thought after posting, there's no way it hasn't been done before. Would you be ok with me deleting it now that you've answered it?
$endgroup$
– Teleporting Goat
12 hours ago














$begingroup$
well I've been searching for a dupe but I'm not very good at the search...we do have a sandbox for posting challenges which can often catch things like that. I'm perfectly OK with you deleting it if you're worried about it being a dupe.
$endgroup$
– Giuseppe
12 hours ago






$begingroup$
well I've been searching for a dupe but I'm not very good at the search...we do have a sandbox for posting challenges which can often catch things like that. I'm perfectly OK with you deleting it if you're worried about it being a dupe.
$endgroup$
– Giuseppe
12 hours ago














$begingroup$
@Giuseppe Well it's too late, with 2 answers SE won't let me delete it. I had hoped for a better start in PPCG...
$endgroup$
– Teleporting Goat
12 hours ago






$begingroup$
@Giuseppe Well it's too late, with 2 answers SE won't let me delete it. I had hoped for a better start in PPCG...
$endgroup$
– Teleporting Goat
12 hours ago






1




1




$begingroup$
Could you add a test case with an even number of strings?
$endgroup$
– Sherlock9
12 hours ago




$begingroup$
Could you add a test case with an even number of strings?
$endgroup$
– Sherlock9
12 hours ago










19 Answers
19






active

oldest

votes


















5












$begingroup$


Python 2, 47 bytes





lambda l:l.sort(key=len)or l[1::2][::-1]+l[::2]


Try it online!






share|improve this answer









$endgroup$













  • $begingroup$
    You'll need to rearrange some stuff, but you can use [::-2] directly to save 5 bytes.
    $endgroup$
    – Sherlock9
    12 hours ago










  • $begingroup$
    @Sherlock9 I tried that, but then I had to check for the length, as lists with even / uneven lengths have to be handled differently.
    $endgroup$
    – ovs
    12 hours ago



















4












$begingroup$


Jelly, 9 8 bytes



LÞŒœm"-Ẏ


Try it online!



LÞŒœṚ;¥/


is also 8 bytes.



Thanks to @EriktheOutgolfer and @JonathanAllan for both offering golfs to save a byte.






share|improve this answer











$endgroup$













  • $begingroup$
    Nice! Clever golf: Ṛ€1¦ can become m"-.
    $endgroup$
    – Erik the Outgolfer
    11 hours ago










  • $begingroup$
    Or you could go for LÞŒœṚ;¥/
    $endgroup$
    – Jonathan Allan
    10 hours ago



















3












$begingroup$


C# (Visual C# Interactive Compiler), 89 bytes





n=>(n=n.OrderBy(x=>x.Length)).Where((a,b)=>b%2>0).Reverse().Concat(n.Where((a,b)=>b%2<1))


Try it online!






share|improve this answer









$endgroup$





















    3












    $begingroup$


    K (oK), 24 bytes



    Solution:



    x(<#:'x)(|&~w),&w:2!!#x:


    Try it online!



    Explanation:



    Generate the 6 4 2 0 1 3 5 sequence, use that to index into the ascending lengths of input, and use that to index into the original array:



    x(<#:'x)(|&~w),&w:2!!#x: / the solution
    x: / save input as x
    # / count (#) of x
    ! / range 0 to ...
    2! / modulo 2
    w: / save as w
    & / indices where true
    , / join with
    ( ) / do this together
    ~w / not (~) w
    & / indices where true
    | / reverse
    ( ) / do this together
    #:'x / count (#:) of each (') x
    < / indices to sort ascending
    x / index into x





    share|improve this answer











    $endgroup$





















      3












      $begingroup$


      R, 63 48 bytes





      function(L)c(rev(o<-L[order(nchar(L))]),o)[!0:1]


      Try it online!



      Sort by string lengths, then combine the reversed list with the sorted list, finally, take every 2nd element, starting at 1-based index 1.






      share|improve this answer











      $endgroup$





















        2












        $begingroup$


        J, 12 bytes



        ,~`,/@:#&> 


        Try it online!



        We sort it down first.



        Then we reduce the list form right to left, but alternating which side we put the new element on. Done.






        share|improve this answer











        $endgroup$





















          1












          $begingroup$


          PHP, 144 bytes





          function($a){usort($a,function($b,$c){return strlen($b)-strlen($c);});$e=;foreach($a as$d)[array_unshift,array_push][++$i%2]($e,$d);return$e;}


          Try it online!



          Sadly, PHP just doesn't have a lot of syntactic sugar to make this shorter. Submitting it anyway!






          share|improve this answer









          $endgroup$





















            1












            $begingroup$

            APL+WIN, 31 38 bytes



            See Adams comment



            ⊃n[(⍳⍴n)~a],⌽n[a←2×⍳⌊.5×⍴n←n[⍒∊⍴¨n←⎕]]


            Try it online Courtesy of Dyalog Classic!



            Prompts for a nested vector of strings






            share|improve this answer











            $endgroup$













            • $begingroup$
              Does APL+ not have Monadic "tally" to replace ∊⍴ ?
              $endgroup$
              – Adám
              10 hours ago








            • 1




              $begingroup$
              Fails on '12' '1234' '1234' '1234' '1234' '12345678' '12345678' '12345678' '12345678'. Clearly, the result should have been '12345678' '12345678' '1234' '1234' '12' '1234' '1234' '12345678' '12345678'
              $endgroup$
              – Adám
              10 hours ago










            • $begingroup$
              @Adám My ancient version of APL+ does not have ≢. Agreed on your second comment I will take a look at it tomorrow.
              $endgroup$
              – Graham
              10 hours ago



















            1












            $begingroup$


            PowerShell, 66 bytes





            1..($a=$args|sort l*).count|?{$_%2}|%{$a[-$_];$x=,$a[-++$_]+$x};$x


            Try it online!



            Takes input via splatting, which manifests on TIO as separate command-line arguments. sorts on the length, stores that into $a, and constructs a range from 1 up to the count of input strings. We then pull out only the odd ones ?{$_%2} and feed those into a loop |%{...}. Each iteration, we put the "last", then the "third from last", and so on onto the pipeline with $a[-$_]. Separately, we also accumulate into $x the "second from last", "fourth from last", etc. Out of the loop and the pipeline is flushed (so those elements are output) and then we output $x. In both instances, the default output gives us newlines between items automatically.






            share|improve this answer









            $endgroup$





















              1












              $begingroup$


              Ruby, 51 bytes





              ->l{r=1;l.sort_by!(&:size).map{l[r-=2]||(l*2)[~r]}}


              Try it online!






              share|improve this answer









              $endgroup$





















                1












                $begingroup$

                Japt, 8 bytes



                ñÊó g0_w


                -3 bytes thanks to Shaggy!



                Try it






                share|improve this answer











                $endgroup$













                • $begingroup$
                  10 bytes with output as a 2D-array, which would seem to be allowed.
                  $endgroup$
                  – Shaggy
                  8 hours ago










                • $begingroup$
                  Or, maybe, 8 bytes? On my phone so haven't tested it properly.
                  $endgroup$
                  – Shaggy
                  8 hours ago










                • $begingroup$
                  @Shaggy I was looking for a function to find every nth element, but I couldn't find it. Thanks!
                  $endgroup$
                  – Embodiment of Ignorance
                  8 hours ago










                • $begingroup$
                  there's also A.ë() but I don't know if that'll lead to a shorter solution.
                  $endgroup$
                  – Shaggy
                  7 hours ago



















                0












                $begingroup$

                Javascript 79 bytes



                Takes input as an array of strings, outputs an arrow-sorted array of strings.



                f=s=>s.sort((a,b)=>a.length-b.length).reduce((m,x,i)=>i%2?[...m,x]:[x,...m],)


                Explanation



                f = s =>                             // take input as an array of strings s
                s.sort((a,b)=>a.length-b.length) // sort input by string length
                .reduce( // reduce
                (m,x,i)=>i%2?[...m,x]:[x,...m], // if index is even, stick string x at the end of the memo
                // array, else at the beginning
                // memo initialized to empty array
                )





                share|improve this answer









                $endgroup$





















                  0












                  $begingroup$


                  Retina, 26 bytes



                  N$`
                  $.&
                  *,2,^A`.+
                  ,2,G`.+


                  Try it online! Explanation:



                  N$`
                  $.&


                  Sort the lines in ascending order of length ($.& returns the length of the line).



                  *,2,^A`.+


                  Temporarily delete alternate lines and output the remaining lines in reverse order.



                  ,2,G`.+


                  Keep the only lines that were temporarily deleted and output them.






                  share|improve this answer









                  $endgroup$





















                    0












                    $begingroup$


                    Gaia, 10 bytes



                    el∫v:v+2%ụ


                    Try it online!



                    e		| eval as Gaia code (list of strings)
                    l∫ | ∫ort by lengths (ascending)
                    v:v | reverse, dup, reverse
                    + | concatenate lists
                    2% | take every other element
                    ụ | join by newlines and output





                    share|improve this answer









                    $endgroup$









                    • 1




                      $begingroup$
                      i like that your comments in unwrapped code form an arrow of strings
                      $endgroup$
                      – aaaaaa
                      5 hours ago



















                    0












                    $begingroup$


                    C (gcc), 136 bytes





                    S(a,b)char**a,**b;{a=strlen(*b)-strlen(*a);}f(l,s,o,t,i,b,e)char**s,**o,*t;{qsort(s,l,8,S);e=l-1;for(i=b=0;i-l;++i)o[i%2?b++:e--]=s[i];}


                    Try it online!



                    The function f is the solution. It takes the number of strings, the strings themselves, and the output buffer as arguments (plus four more used internally).






                    share|improve this answer









                    $endgroup$













                    • $begingroup$
                      Why is ./.bin.tio in the output?
                      $endgroup$
                      – Teleporting Goat
                      7 hours ago










                    • $begingroup$
                      @TeleportingGoat Probably because their footer is using all of argv, which includes the filename
                      $endgroup$
                      – Jo King
                      3 hours ago



















                    0












                    $begingroup$

                    MATLAB, 92 bytes



                    function f(y);[B,I]=sort(cellfun(@(x)length(x),y));disp({y{I(end:-2:1)},y{I(1:2:end)}}');end


                    Takes input as cell array of strings, outputs column of strings (not sure if that's legal)



                    > s = {'qweq qwe qw','qweqw','12132132131231231','asdasdasda','qwe','w'};
                    > f(s);
                    >
                    > function f(y);[B,I]=sort(cellfun(@(x)length(x),y));disp({y{I(end:-2:1)},y{I(1:2:end)}}');end
                    >
                    > >>
                    > '12132132131231231'
                    > 'asdasdasda'
                    > 'qwe'
                    > 'w'
                    > 'qweqw'
                    > 'qweq qwe qw'





                    share|improve this answer









                    $endgroup$





















                      0












                      $begingroup$

                      T-SQL, 99 bytes



                      Input is a table



                      DECLARE @ table(a varchar(80))
                      INSERT @ values
                      ('sheriffOfNottingham'),('kingRichard'),('maidMarian'),
                      ('bow'),('arrows'),('princeJohn'),('sherwoodForest')

                      SELECT a FROM(SELECT*,row_number()over(order by
                      len(a))r,sum(1)over()c FROM @)x
                      ORDER BY abs(c/2-r)


                      Try it online






                      share|improve this answer









                      $endgroup$





















                        0












                        $begingroup$


                        PowerShell, 49 bytes





                        $args|sort l*|sort{$_.Length*($global:x=-$x*2+1)}


                        Try it online!



                        The double distillation.






                        share|improve this answer











                        $endgroup$





















                          -1












                          $begingroup$

                          Javascript 95 Bytes



                          s=>s.sort((x,y)=>x.length-y.length).reduce((a,e,i)=>{i%2?a.push(e):a.unshift(e);return a;},);





                          share|improve this answer










                          New contributor




                          somsom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          $endgroup$













                          • $begingroup$
                            -1 s.sort() sorts the strings lexicographically, not by string length.
                            $endgroup$
                            – asgallant
                            10 hours ago










                          • $begingroup$
                            Right, (x,y)=>x.length-y.length, should fix that.
                            $endgroup$
                            – somsom
                            10 hours ago












                          Your Answer





                          StackExchange.ifUsing("editor", function () {
                          return StackExchange.using("mathjaxEditing", function () {
                          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                          });
                          });
                          }, "mathjax-editing");

                          StackExchange.ifUsing("editor", function () {
                          StackExchange.using("externalEditor", function () {
                          StackExchange.using("snippets", function () {
                          StackExchange.snippets.init();
                          });
                          });
                          }, "code-snippets");

                          StackExchange.ready(function() {
                          var channelOptions = {
                          tags: "".split(" "),
                          id: "200"
                          };
                          initTagRenderer("".split(" "), "".split(" "), channelOptions);

                          StackExchange.using("externalEditor", function() {
                          // Have to fire editor after snippets, if snippets enabled
                          if (StackExchange.settings.snippets.snippetsEnabled) {
                          StackExchange.using("snippets", function() {
                          createEditor();
                          });
                          }
                          else {
                          createEditor();
                          }
                          });

                          function createEditor() {
                          StackExchange.prepareEditor({
                          heartbeatType: 'answer',
                          autoActivateHeartbeat: false,
                          convertImagesToLinks: false,
                          noModals: true,
                          showLowRepImageUploadWarning: true,
                          reputationToPostImages: null,
                          bindNavPrevention: true,
                          postfix: "",
                          imageUploader: {
                          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                          allowUrls: true
                          },
                          onDemand: true,
                          discardSelector: ".discard-answer"
                          ,immediatelyShowMarkdownHelp:true
                          });


                          }
                          });






                          Teleporting Goat is a new contributor. Be nice, and check out our Code of Conduct.










                          draft saved

                          draft discarded


















                          StackExchange.ready(
                          function () {
                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182615%2farrow-those-variables%23new-answer', 'question_page');
                          }
                          );

                          Post as a guest















                          Required, but never shown

























                          19 Answers
                          19






                          active

                          oldest

                          votes








                          19 Answers
                          19






                          active

                          oldest

                          votes









                          active

                          oldest

                          votes






                          active

                          oldest

                          votes









                          5












                          $begingroup$


                          Python 2, 47 bytes





                          lambda l:l.sort(key=len)or l[1::2][::-1]+l[::2]


                          Try it online!






                          share|improve this answer









                          $endgroup$













                          • $begingroup$
                            You'll need to rearrange some stuff, but you can use [::-2] directly to save 5 bytes.
                            $endgroup$
                            – Sherlock9
                            12 hours ago










                          • $begingroup$
                            @Sherlock9 I tried that, but then I had to check for the length, as lists with even / uneven lengths have to be handled differently.
                            $endgroup$
                            – ovs
                            12 hours ago
















                          5












                          $begingroup$


                          Python 2, 47 bytes





                          lambda l:l.sort(key=len)or l[1::2][::-1]+l[::2]


                          Try it online!






                          share|improve this answer









                          $endgroup$













                          • $begingroup$
                            You'll need to rearrange some stuff, but you can use [::-2] directly to save 5 bytes.
                            $endgroup$
                            – Sherlock9
                            12 hours ago










                          • $begingroup$
                            @Sherlock9 I tried that, but then I had to check for the length, as lists with even / uneven lengths have to be handled differently.
                            $endgroup$
                            – ovs
                            12 hours ago














                          5












                          5








                          5





                          $begingroup$


                          Python 2, 47 bytes





                          lambda l:l.sort(key=len)or l[1::2][::-1]+l[::2]


                          Try it online!






                          share|improve this answer









                          $endgroup$




                          Python 2, 47 bytes





                          lambda l:l.sort(key=len)or l[1::2][::-1]+l[::2]


                          Try it online!







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 12 hours ago









                          ovsovs

                          19.4k21160




                          19.4k21160












                          • $begingroup$
                            You'll need to rearrange some stuff, but you can use [::-2] directly to save 5 bytes.
                            $endgroup$
                            – Sherlock9
                            12 hours ago










                          • $begingroup$
                            @Sherlock9 I tried that, but then I had to check for the length, as lists with even / uneven lengths have to be handled differently.
                            $endgroup$
                            – ovs
                            12 hours ago


















                          • $begingroup$
                            You'll need to rearrange some stuff, but you can use [::-2] directly to save 5 bytes.
                            $endgroup$
                            – Sherlock9
                            12 hours ago










                          • $begingroup$
                            @Sherlock9 I tried that, but then I had to check for the length, as lists with even / uneven lengths have to be handled differently.
                            $endgroup$
                            – ovs
                            12 hours ago
















                          $begingroup$
                          You'll need to rearrange some stuff, but you can use [::-2] directly to save 5 bytes.
                          $endgroup$
                          – Sherlock9
                          12 hours ago




                          $begingroup$
                          You'll need to rearrange some stuff, but you can use [::-2] directly to save 5 bytes.
                          $endgroup$
                          – Sherlock9
                          12 hours ago












                          $begingroup$
                          @Sherlock9 I tried that, but then I had to check for the length, as lists with even / uneven lengths have to be handled differently.
                          $endgroup$
                          – ovs
                          12 hours ago




                          $begingroup$
                          @Sherlock9 I tried that, but then I had to check for the length, as lists with even / uneven lengths have to be handled differently.
                          $endgroup$
                          – ovs
                          12 hours ago











                          4












                          $begingroup$


                          Jelly, 9 8 bytes



                          LÞŒœm"-Ẏ


                          Try it online!



                          LÞŒœṚ;¥/


                          is also 8 bytes.



                          Thanks to @EriktheOutgolfer and @JonathanAllan for both offering golfs to save a byte.






                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            Nice! Clever golf: Ṛ€1¦ can become m"-.
                            $endgroup$
                            – Erik the Outgolfer
                            11 hours ago










                          • $begingroup$
                            Or you could go for LÞŒœṚ;¥/
                            $endgroup$
                            – Jonathan Allan
                            10 hours ago
















                          4












                          $begingroup$


                          Jelly, 9 8 bytes



                          LÞŒœm"-Ẏ


                          Try it online!



                          LÞŒœṚ;¥/


                          is also 8 bytes.



                          Thanks to @EriktheOutgolfer and @JonathanAllan for both offering golfs to save a byte.






                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            Nice! Clever golf: Ṛ€1¦ can become m"-.
                            $endgroup$
                            – Erik the Outgolfer
                            11 hours ago










                          • $begingroup$
                            Or you could go for LÞŒœṚ;¥/
                            $endgroup$
                            – Jonathan Allan
                            10 hours ago














                          4












                          4








                          4





                          $begingroup$


                          Jelly, 9 8 bytes



                          LÞŒœm"-Ẏ


                          Try it online!



                          LÞŒœṚ;¥/


                          is also 8 bytes.



                          Thanks to @EriktheOutgolfer and @JonathanAllan for both offering golfs to save a byte.






                          share|improve this answer











                          $endgroup$




                          Jelly, 9 8 bytes



                          LÞŒœm"-Ẏ


                          Try it online!



                          LÞŒœṚ;¥/


                          is also 8 bytes.



                          Thanks to @EriktheOutgolfer and @JonathanAllan for both offering golfs to save a byte.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 10 hours ago

























                          answered 12 hours ago









                          Nick KennedyNick Kennedy

                          1,29649




                          1,29649












                          • $begingroup$
                            Nice! Clever golf: Ṛ€1¦ can become m"-.
                            $endgroup$
                            – Erik the Outgolfer
                            11 hours ago










                          • $begingroup$
                            Or you could go for LÞŒœṚ;¥/
                            $endgroup$
                            – Jonathan Allan
                            10 hours ago


















                          • $begingroup$
                            Nice! Clever golf: Ṛ€1¦ can become m"-.
                            $endgroup$
                            – Erik the Outgolfer
                            11 hours ago










                          • $begingroup$
                            Or you could go for LÞŒœṚ;¥/
                            $endgroup$
                            – Jonathan Allan
                            10 hours ago
















                          $begingroup$
                          Nice! Clever golf: Ṛ€1¦ can become m"-.
                          $endgroup$
                          – Erik the Outgolfer
                          11 hours ago




                          $begingroup$
                          Nice! Clever golf: Ṛ€1¦ can become m"-.
                          $endgroup$
                          – Erik the Outgolfer
                          11 hours ago












                          $begingroup$
                          Or you could go for LÞŒœṚ;¥/
                          $endgroup$
                          – Jonathan Allan
                          10 hours ago




                          $begingroup$
                          Or you could go for LÞŒœṚ;¥/
                          $endgroup$
                          – Jonathan Allan
                          10 hours ago











                          3












                          $begingroup$


                          C# (Visual C# Interactive Compiler), 89 bytes





                          n=>(n=n.OrderBy(x=>x.Length)).Where((a,b)=>b%2>0).Reverse().Concat(n.Where((a,b)=>b%2<1))


                          Try it online!






                          share|improve this answer









                          $endgroup$


















                            3












                            $begingroup$


                            C# (Visual C# Interactive Compiler), 89 bytes





                            n=>(n=n.OrderBy(x=>x.Length)).Where((a,b)=>b%2>0).Reverse().Concat(n.Where((a,b)=>b%2<1))


                            Try it online!






                            share|improve this answer









                            $endgroup$
















                              3












                              3








                              3





                              $begingroup$


                              C# (Visual C# Interactive Compiler), 89 bytes





                              n=>(n=n.OrderBy(x=>x.Length)).Where((a,b)=>b%2>0).Reverse().Concat(n.Where((a,b)=>b%2<1))


                              Try it online!






                              share|improve this answer









                              $endgroup$




                              C# (Visual C# Interactive Compiler), 89 bytes





                              n=>(n=n.OrderBy(x=>x.Length)).Where((a,b)=>b%2>0).Reverse().Concat(n.Where((a,b)=>b%2<1))


                              Try it online!







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered 12 hours ago









                              Embodiment of IgnoranceEmbodiment of Ignorance

                              2,358126




                              2,358126























                                  3












                                  $begingroup$


                                  K (oK), 24 bytes



                                  Solution:



                                  x(<#:'x)(|&~w),&w:2!!#x:


                                  Try it online!



                                  Explanation:



                                  Generate the 6 4 2 0 1 3 5 sequence, use that to index into the ascending lengths of input, and use that to index into the original array:



                                  x(<#:'x)(|&~w),&w:2!!#x: / the solution
                                  x: / save input as x
                                  # / count (#) of x
                                  ! / range 0 to ...
                                  2! / modulo 2
                                  w: / save as w
                                  & / indices where true
                                  , / join with
                                  ( ) / do this together
                                  ~w / not (~) w
                                  & / indices where true
                                  | / reverse
                                  ( ) / do this together
                                  #:'x / count (#:) of each (') x
                                  < / indices to sort ascending
                                  x / index into x





                                  share|improve this answer











                                  $endgroup$


















                                    3












                                    $begingroup$


                                    K (oK), 24 bytes



                                    Solution:



                                    x(<#:'x)(|&~w),&w:2!!#x:


                                    Try it online!



                                    Explanation:



                                    Generate the 6 4 2 0 1 3 5 sequence, use that to index into the ascending lengths of input, and use that to index into the original array:



                                    x(<#:'x)(|&~w),&w:2!!#x: / the solution
                                    x: / save input as x
                                    # / count (#) of x
                                    ! / range 0 to ...
                                    2! / modulo 2
                                    w: / save as w
                                    & / indices where true
                                    , / join with
                                    ( ) / do this together
                                    ~w / not (~) w
                                    & / indices where true
                                    | / reverse
                                    ( ) / do this together
                                    #:'x / count (#:) of each (') x
                                    < / indices to sort ascending
                                    x / index into x





                                    share|improve this answer











                                    $endgroup$
















                                      3












                                      3








                                      3





                                      $begingroup$


                                      K (oK), 24 bytes



                                      Solution:



                                      x(<#:'x)(|&~w),&w:2!!#x:


                                      Try it online!



                                      Explanation:



                                      Generate the 6 4 2 0 1 3 5 sequence, use that to index into the ascending lengths of input, and use that to index into the original array:



                                      x(<#:'x)(|&~w),&w:2!!#x: / the solution
                                      x: / save input as x
                                      # / count (#) of x
                                      ! / range 0 to ...
                                      2! / modulo 2
                                      w: / save as w
                                      & / indices where true
                                      , / join with
                                      ( ) / do this together
                                      ~w / not (~) w
                                      & / indices where true
                                      | / reverse
                                      ( ) / do this together
                                      #:'x / count (#:) of each (') x
                                      < / indices to sort ascending
                                      x / index into x





                                      share|improve this answer











                                      $endgroup$




                                      K (oK), 24 bytes



                                      Solution:



                                      x(<#:'x)(|&~w),&w:2!!#x:


                                      Try it online!



                                      Explanation:



                                      Generate the 6 4 2 0 1 3 5 sequence, use that to index into the ascending lengths of input, and use that to index into the original array:



                                      x(<#:'x)(|&~w),&w:2!!#x: / the solution
                                      x: / save input as x
                                      # / count (#) of x
                                      ! / range 0 to ...
                                      2! / modulo 2
                                      w: / save as w
                                      & / indices where true
                                      , / join with
                                      ( ) / do this together
                                      ~w / not (~) w
                                      & / indices where true
                                      | / reverse
                                      ( ) / do this together
                                      #:'x / count (#:) of each (') x
                                      < / indices to sort ascending
                                      x / index into x






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 11 hours ago

























                                      answered 11 hours ago









                                      streetsterstreetster

                                      2,624515




                                      2,624515























                                          3












                                          $begingroup$


                                          R, 63 48 bytes





                                          function(L)c(rev(o<-L[order(nchar(L))]),o)[!0:1]


                                          Try it online!



                                          Sort by string lengths, then combine the reversed list with the sorted list, finally, take every 2nd element, starting at 1-based index 1.






                                          share|improve this answer











                                          $endgroup$


















                                            3












                                            $begingroup$


                                            R, 63 48 bytes





                                            function(L)c(rev(o<-L[order(nchar(L))]),o)[!0:1]


                                            Try it online!



                                            Sort by string lengths, then combine the reversed list with the sorted list, finally, take every 2nd element, starting at 1-based index 1.






                                            share|improve this answer











                                            $endgroup$
















                                              3












                                              3








                                              3





                                              $begingroup$


                                              R, 63 48 bytes





                                              function(L)c(rev(o<-L[order(nchar(L))]),o)[!0:1]


                                              Try it online!



                                              Sort by string lengths, then combine the reversed list with the sorted list, finally, take every 2nd element, starting at 1-based index 1.






                                              share|improve this answer











                                              $endgroup$




                                              R, 63 48 bytes





                                              function(L)c(rev(o<-L[order(nchar(L))]),o)[!0:1]


                                              Try it online!



                                              Sort by string lengths, then combine the reversed list with the sorted list, finally, take every 2nd element, starting at 1-based index 1.







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited 8 hours ago

























                                              answered 12 hours ago









                                              GiuseppeGiuseppe

                                              17.4k31152




                                              17.4k31152























                                                  2












                                                  $begingroup$


                                                  J, 12 bytes



                                                  ,~`,/@:#&> 


                                                  Try it online!



                                                  We sort it down first.



                                                  Then we reduce the list form right to left, but alternating which side we put the new element on. Done.






                                                  share|improve this answer











                                                  $endgroup$


















                                                    2












                                                    $begingroup$


                                                    J, 12 bytes



                                                    ,~`,/@:#&> 


                                                    Try it online!



                                                    We sort it down first.



                                                    Then we reduce the list form right to left, but alternating which side we put the new element on. Done.






                                                    share|improve this answer











                                                    $endgroup$
















                                                      2












                                                      2








                                                      2





                                                      $begingroup$


                                                      J, 12 bytes



                                                      ,~`,/@:#&> 


                                                      Try it online!



                                                      We sort it down first.



                                                      Then we reduce the list form right to left, but alternating which side we put the new element on. Done.






                                                      share|improve this answer











                                                      $endgroup$




                                                      J, 12 bytes



                                                      ,~`,/@:#&> 


                                                      Try it online!



                                                      We sort it down first.



                                                      Then we reduce the list form right to left, but alternating which side we put the new element on. Done.







                                                      share|improve this answer














                                                      share|improve this answer



                                                      share|improve this answer








                                                      edited 4 hours ago

























                                                      answered 7 hours ago









                                                      JonahJonah

                                                      2,5111017




                                                      2,5111017























                                                          1












                                                          $begingroup$


                                                          PHP, 144 bytes





                                                          function($a){usort($a,function($b,$c){return strlen($b)-strlen($c);});$e=;foreach($a as$d)[array_unshift,array_push][++$i%2]($e,$d);return$e;}


                                                          Try it online!



                                                          Sadly, PHP just doesn't have a lot of syntactic sugar to make this shorter. Submitting it anyway!






                                                          share|improve this answer









                                                          $endgroup$


















                                                            1












                                                            $begingroup$


                                                            PHP, 144 bytes





                                                            function($a){usort($a,function($b,$c){return strlen($b)-strlen($c);});$e=;foreach($a as$d)[array_unshift,array_push][++$i%2]($e,$d);return$e;}


                                                            Try it online!



                                                            Sadly, PHP just doesn't have a lot of syntactic sugar to make this shorter. Submitting it anyway!






                                                            share|improve this answer









                                                            $endgroup$
















                                                              1












                                                              1








                                                              1





                                                              $begingroup$


                                                              PHP, 144 bytes





                                                              function($a){usort($a,function($b,$c){return strlen($b)-strlen($c);});$e=;foreach($a as$d)[array_unshift,array_push][++$i%2]($e,$d);return$e;}


                                                              Try it online!



                                                              Sadly, PHP just doesn't have a lot of syntactic sugar to make this shorter. Submitting it anyway!






                                                              share|improve this answer









                                                              $endgroup$




                                                              PHP, 144 bytes





                                                              function($a){usort($a,function($b,$c){return strlen($b)-strlen($c);});$e=;foreach($a as$d)[array_unshift,array_push][++$i%2]($e,$d);return$e;}


                                                              Try it online!



                                                              Sadly, PHP just doesn't have a lot of syntactic sugar to make this shorter. Submitting it anyway!







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered 10 hours ago









                                                              gwaughgwaugh

                                                              2,068516




                                                              2,068516























                                                                  1












                                                                  $begingroup$

                                                                  APL+WIN, 31 38 bytes



                                                                  See Adams comment



                                                                  ⊃n[(⍳⍴n)~a],⌽n[a←2×⍳⌊.5×⍴n←n[⍒∊⍴¨n←⎕]]


                                                                  Try it online Courtesy of Dyalog Classic!



                                                                  Prompts for a nested vector of strings






                                                                  share|improve this answer











                                                                  $endgroup$













                                                                  • $begingroup$
                                                                    Does APL+ not have Monadic "tally" to replace ∊⍴ ?
                                                                    $endgroup$
                                                                    – Adám
                                                                    10 hours ago








                                                                  • 1




                                                                    $begingroup$
                                                                    Fails on '12' '1234' '1234' '1234' '1234' '12345678' '12345678' '12345678' '12345678'. Clearly, the result should have been '12345678' '12345678' '1234' '1234' '12' '1234' '1234' '12345678' '12345678'
                                                                    $endgroup$
                                                                    – Adám
                                                                    10 hours ago










                                                                  • $begingroup$
                                                                    @Adám My ancient version of APL+ does not have ≢. Agreed on your second comment I will take a look at it tomorrow.
                                                                    $endgroup$
                                                                    – Graham
                                                                    10 hours ago
















                                                                  1












                                                                  $begingroup$

                                                                  APL+WIN, 31 38 bytes



                                                                  See Adams comment



                                                                  ⊃n[(⍳⍴n)~a],⌽n[a←2×⍳⌊.5×⍴n←n[⍒∊⍴¨n←⎕]]


                                                                  Try it online Courtesy of Dyalog Classic!



                                                                  Prompts for a nested vector of strings






                                                                  share|improve this answer











                                                                  $endgroup$













                                                                  • $begingroup$
                                                                    Does APL+ not have Monadic "tally" to replace ∊⍴ ?
                                                                    $endgroup$
                                                                    – Adám
                                                                    10 hours ago








                                                                  • 1




                                                                    $begingroup$
                                                                    Fails on '12' '1234' '1234' '1234' '1234' '12345678' '12345678' '12345678' '12345678'. Clearly, the result should have been '12345678' '12345678' '1234' '1234' '12' '1234' '1234' '12345678' '12345678'
                                                                    $endgroup$
                                                                    – Adám
                                                                    10 hours ago










                                                                  • $begingroup$
                                                                    @Adám My ancient version of APL+ does not have ≢. Agreed on your second comment I will take a look at it tomorrow.
                                                                    $endgroup$
                                                                    – Graham
                                                                    10 hours ago














                                                                  1












                                                                  1








                                                                  1





                                                                  $begingroup$

                                                                  APL+WIN, 31 38 bytes



                                                                  See Adams comment



                                                                  ⊃n[(⍳⍴n)~a],⌽n[a←2×⍳⌊.5×⍴n←n[⍒∊⍴¨n←⎕]]


                                                                  Try it online Courtesy of Dyalog Classic!



                                                                  Prompts for a nested vector of strings






                                                                  share|improve this answer











                                                                  $endgroup$



                                                                  APL+WIN, 31 38 bytes



                                                                  See Adams comment



                                                                  ⊃n[(⍳⍴n)~a],⌽n[a←2×⍳⌊.5×⍴n←n[⍒∊⍴¨n←⎕]]


                                                                  Try it online Courtesy of Dyalog Classic!



                                                                  Prompts for a nested vector of strings







                                                                  share|improve this answer














                                                                  share|improve this answer



                                                                  share|improve this answer








                                                                  edited 10 hours ago

























                                                                  answered 10 hours ago









                                                                  GrahamGraham

                                                                  2,62678




                                                                  2,62678












                                                                  • $begingroup$
                                                                    Does APL+ not have Monadic "tally" to replace ∊⍴ ?
                                                                    $endgroup$
                                                                    – Adám
                                                                    10 hours ago








                                                                  • 1




                                                                    $begingroup$
                                                                    Fails on '12' '1234' '1234' '1234' '1234' '12345678' '12345678' '12345678' '12345678'. Clearly, the result should have been '12345678' '12345678' '1234' '1234' '12' '1234' '1234' '12345678' '12345678'
                                                                    $endgroup$
                                                                    – Adám
                                                                    10 hours ago










                                                                  • $begingroup$
                                                                    @Adám My ancient version of APL+ does not have ≢. Agreed on your second comment I will take a look at it tomorrow.
                                                                    $endgroup$
                                                                    – Graham
                                                                    10 hours ago


















                                                                  • $begingroup$
                                                                    Does APL+ not have Monadic "tally" to replace ∊⍴ ?
                                                                    $endgroup$
                                                                    – Adám
                                                                    10 hours ago








                                                                  • 1




                                                                    $begingroup$
                                                                    Fails on '12' '1234' '1234' '1234' '1234' '12345678' '12345678' '12345678' '12345678'. Clearly, the result should have been '12345678' '12345678' '1234' '1234' '12' '1234' '1234' '12345678' '12345678'
                                                                    $endgroup$
                                                                    – Adám
                                                                    10 hours ago










                                                                  • $begingroup$
                                                                    @Adám My ancient version of APL+ does not have ≢. Agreed on your second comment I will take a look at it tomorrow.
                                                                    $endgroup$
                                                                    – Graham
                                                                    10 hours ago
















                                                                  $begingroup$
                                                                  Does APL+ not have Monadic "tally" to replace ∊⍴ ?
                                                                  $endgroup$
                                                                  – Adám
                                                                  10 hours ago






                                                                  $begingroup$
                                                                  Does APL+ not have Monadic "tally" to replace ∊⍴ ?
                                                                  $endgroup$
                                                                  – Adám
                                                                  10 hours ago






                                                                  1




                                                                  1




                                                                  $begingroup$
                                                                  Fails on '12' '1234' '1234' '1234' '1234' '12345678' '12345678' '12345678' '12345678'. Clearly, the result should have been '12345678' '12345678' '1234' '1234' '12' '1234' '1234' '12345678' '12345678'
                                                                  $endgroup$
                                                                  – Adám
                                                                  10 hours ago




                                                                  $begingroup$
                                                                  Fails on '12' '1234' '1234' '1234' '1234' '12345678' '12345678' '12345678' '12345678'. Clearly, the result should have been '12345678' '12345678' '1234' '1234' '12' '1234' '1234' '12345678' '12345678'
                                                                  $endgroup$
                                                                  – Adám
                                                                  10 hours ago












                                                                  $begingroup$
                                                                  @Adám My ancient version of APL+ does not have ≢. Agreed on your second comment I will take a look at it tomorrow.
                                                                  $endgroup$
                                                                  – Graham
                                                                  10 hours ago




                                                                  $begingroup$
                                                                  @Adám My ancient version of APL+ does not have ≢. Agreed on your second comment I will take a look at it tomorrow.
                                                                  $endgroup$
                                                                  – Graham
                                                                  10 hours ago











                                                                  1












                                                                  $begingroup$


                                                                  PowerShell, 66 bytes





                                                                  1..($a=$args|sort l*).count|?{$_%2}|%{$a[-$_];$x=,$a[-++$_]+$x};$x


                                                                  Try it online!



                                                                  Takes input via splatting, which manifests on TIO as separate command-line arguments. sorts on the length, stores that into $a, and constructs a range from 1 up to the count of input strings. We then pull out only the odd ones ?{$_%2} and feed those into a loop |%{...}. Each iteration, we put the "last", then the "third from last", and so on onto the pipeline with $a[-$_]. Separately, we also accumulate into $x the "second from last", "fourth from last", etc. Out of the loop and the pipeline is flushed (so those elements are output) and then we output $x. In both instances, the default output gives us newlines between items automatically.






                                                                  share|improve this answer









                                                                  $endgroup$


















                                                                    1












                                                                    $begingroup$


                                                                    PowerShell, 66 bytes





                                                                    1..($a=$args|sort l*).count|?{$_%2}|%{$a[-$_];$x=,$a[-++$_]+$x};$x


                                                                    Try it online!



                                                                    Takes input via splatting, which manifests on TIO as separate command-line arguments. sorts on the length, stores that into $a, and constructs a range from 1 up to the count of input strings. We then pull out only the odd ones ?{$_%2} and feed those into a loop |%{...}. Each iteration, we put the "last", then the "third from last", and so on onto the pipeline with $a[-$_]. Separately, we also accumulate into $x the "second from last", "fourth from last", etc. Out of the loop and the pipeline is flushed (so those elements are output) and then we output $x. In both instances, the default output gives us newlines between items automatically.






                                                                    share|improve this answer









                                                                    $endgroup$
















                                                                      1












                                                                      1








                                                                      1





                                                                      $begingroup$


                                                                      PowerShell, 66 bytes





                                                                      1..($a=$args|sort l*).count|?{$_%2}|%{$a[-$_];$x=,$a[-++$_]+$x};$x


                                                                      Try it online!



                                                                      Takes input via splatting, which manifests on TIO as separate command-line arguments. sorts on the length, stores that into $a, and constructs a range from 1 up to the count of input strings. We then pull out only the odd ones ?{$_%2} and feed those into a loop |%{...}. Each iteration, we put the "last", then the "third from last", and so on onto the pipeline with $a[-$_]. Separately, we also accumulate into $x the "second from last", "fourth from last", etc. Out of the loop and the pipeline is flushed (so those elements are output) and then we output $x. In both instances, the default output gives us newlines between items automatically.






                                                                      share|improve this answer









                                                                      $endgroup$




                                                                      PowerShell, 66 bytes





                                                                      1..($a=$args|sort l*).count|?{$_%2}|%{$a[-$_];$x=,$a[-++$_]+$x};$x


                                                                      Try it online!



                                                                      Takes input via splatting, which manifests on TIO as separate command-line arguments. sorts on the length, stores that into $a, and constructs a range from 1 up to the count of input strings. We then pull out only the odd ones ?{$_%2} and feed those into a loop |%{...}. Each iteration, we put the "last", then the "third from last", and so on onto the pipeline with $a[-$_]. Separately, we also accumulate into $x the "second from last", "fourth from last", etc. Out of the loop and the pipeline is flushed (so those elements are output) and then we output $x. In both instances, the default output gives us newlines between items automatically.







                                                                      share|improve this answer












                                                                      share|improve this answer



                                                                      share|improve this answer










                                                                      answered 9 hours ago









                                                                      AdmBorkBorkAdmBorkBork

                                                                      27.6k466237




                                                                      27.6k466237























                                                                          1












                                                                          $begingroup$


                                                                          Ruby, 51 bytes





                                                                          ->l{r=1;l.sort_by!(&:size).map{l[r-=2]||(l*2)[~r]}}


                                                                          Try it online!






                                                                          share|improve this answer









                                                                          $endgroup$


















                                                                            1












                                                                            $begingroup$


                                                                            Ruby, 51 bytes





                                                                            ->l{r=1;l.sort_by!(&:size).map{l[r-=2]||(l*2)[~r]}}


                                                                            Try it online!






                                                                            share|improve this answer









                                                                            $endgroup$
















                                                                              1












                                                                              1








                                                                              1





                                                                              $begingroup$


                                                                              Ruby, 51 bytes





                                                                              ->l{r=1;l.sort_by!(&:size).map{l[r-=2]||(l*2)[~r]}}


                                                                              Try it online!






                                                                              share|improve this answer









                                                                              $endgroup$




                                                                              Ruby, 51 bytes





                                                                              ->l{r=1;l.sort_by!(&:size).map{l[r-=2]||(l*2)[~r]}}


                                                                              Try it online!







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered 9 hours ago









                                                                              G BG B

                                                                              8,1361429




                                                                              8,1361429























                                                                                  1












                                                                                  $begingroup$

                                                                                  Japt, 8 bytes



                                                                                  ñÊó g0_w


                                                                                  -3 bytes thanks to Shaggy!



                                                                                  Try it






                                                                                  share|improve this answer











                                                                                  $endgroup$













                                                                                  • $begingroup$
                                                                                    10 bytes with output as a 2D-array, which would seem to be allowed.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    Or, maybe, 8 bytes? On my phone so haven't tested it properly.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    @Shaggy I was looking for a function to find every nth element, but I couldn't find it. Thanks!
                                                                                    $endgroup$
                                                                                    – Embodiment of Ignorance
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    there's also A.ë() but I don't know if that'll lead to a shorter solution.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    7 hours ago
















                                                                                  1












                                                                                  $begingroup$

                                                                                  Japt, 8 bytes



                                                                                  ñÊó g0_w


                                                                                  -3 bytes thanks to Shaggy!



                                                                                  Try it






                                                                                  share|improve this answer











                                                                                  $endgroup$













                                                                                  • $begingroup$
                                                                                    10 bytes with output as a 2D-array, which would seem to be allowed.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    Or, maybe, 8 bytes? On my phone so haven't tested it properly.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    @Shaggy I was looking for a function to find every nth element, but I couldn't find it. Thanks!
                                                                                    $endgroup$
                                                                                    – Embodiment of Ignorance
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    there's also A.ë() but I don't know if that'll lead to a shorter solution.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    7 hours ago














                                                                                  1












                                                                                  1








                                                                                  1





                                                                                  $begingroup$

                                                                                  Japt, 8 bytes



                                                                                  ñÊó g0_w


                                                                                  -3 bytes thanks to Shaggy!



                                                                                  Try it






                                                                                  share|improve this answer











                                                                                  $endgroup$



                                                                                  Japt, 8 bytes



                                                                                  ñÊó g0_w


                                                                                  -3 bytes thanks to Shaggy!



                                                                                  Try it







                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited 8 hours ago

























                                                                                  answered 8 hours ago









                                                                                  Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                  2,358126




                                                                                  2,358126












                                                                                  • $begingroup$
                                                                                    10 bytes with output as a 2D-array, which would seem to be allowed.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    Or, maybe, 8 bytes? On my phone so haven't tested it properly.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    @Shaggy I was looking for a function to find every nth element, but I couldn't find it. Thanks!
                                                                                    $endgroup$
                                                                                    – Embodiment of Ignorance
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    there's also A.ë() but I don't know if that'll lead to a shorter solution.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    7 hours ago


















                                                                                  • $begingroup$
                                                                                    10 bytes with output as a 2D-array, which would seem to be allowed.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    Or, maybe, 8 bytes? On my phone so haven't tested it properly.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    @Shaggy I was looking for a function to find every nth element, but I couldn't find it. Thanks!
                                                                                    $endgroup$
                                                                                    – Embodiment of Ignorance
                                                                                    8 hours ago










                                                                                  • $begingroup$
                                                                                    there's also A.ë() but I don't know if that'll lead to a shorter solution.
                                                                                    $endgroup$
                                                                                    – Shaggy
                                                                                    7 hours ago
















                                                                                  $begingroup$
                                                                                  10 bytes with output as a 2D-array, which would seem to be allowed.
                                                                                  $endgroup$
                                                                                  – Shaggy
                                                                                  8 hours ago




                                                                                  $begingroup$
                                                                                  10 bytes with output as a 2D-array, which would seem to be allowed.
                                                                                  $endgroup$
                                                                                  – Shaggy
                                                                                  8 hours ago












                                                                                  $begingroup$
                                                                                  Or, maybe, 8 bytes? On my phone so haven't tested it properly.
                                                                                  $endgroup$
                                                                                  – Shaggy
                                                                                  8 hours ago




                                                                                  $begingroup$
                                                                                  Or, maybe, 8 bytes? On my phone so haven't tested it properly.
                                                                                  $endgroup$
                                                                                  – Shaggy
                                                                                  8 hours ago












                                                                                  $begingroup$
                                                                                  @Shaggy I was looking for a function to find every nth element, but I couldn't find it. Thanks!
                                                                                  $endgroup$
                                                                                  – Embodiment of Ignorance
                                                                                  8 hours ago




                                                                                  $begingroup$
                                                                                  @Shaggy I was looking for a function to find every nth element, but I couldn't find it. Thanks!
                                                                                  $endgroup$
                                                                                  – Embodiment of Ignorance
                                                                                  8 hours ago












                                                                                  $begingroup$
                                                                                  there's also A.ë() but I don't know if that'll lead to a shorter solution.
                                                                                  $endgroup$
                                                                                  – Shaggy
                                                                                  7 hours ago




                                                                                  $begingroup$
                                                                                  there's also A.ë() but I don't know if that'll lead to a shorter solution.
                                                                                  $endgroup$
                                                                                  – Shaggy
                                                                                  7 hours ago











                                                                                  0












                                                                                  $begingroup$

                                                                                  Javascript 79 bytes



                                                                                  Takes input as an array of strings, outputs an arrow-sorted array of strings.



                                                                                  f=s=>s.sort((a,b)=>a.length-b.length).reduce((m,x,i)=>i%2?[...m,x]:[x,...m],)


                                                                                  Explanation



                                                                                  f = s =>                             // take input as an array of strings s
                                                                                  s.sort((a,b)=>a.length-b.length) // sort input by string length
                                                                                  .reduce( // reduce
                                                                                  (m,x,i)=>i%2?[...m,x]:[x,...m], // if index is even, stick string x at the end of the memo
                                                                                  // array, else at the beginning
                                                                                  // memo initialized to empty array
                                                                                  )





                                                                                  share|improve this answer









                                                                                  $endgroup$


















                                                                                    0












                                                                                    $begingroup$

                                                                                    Javascript 79 bytes



                                                                                    Takes input as an array of strings, outputs an arrow-sorted array of strings.



                                                                                    f=s=>s.sort((a,b)=>a.length-b.length).reduce((m,x,i)=>i%2?[...m,x]:[x,...m],)


                                                                                    Explanation



                                                                                    f = s =>                             // take input as an array of strings s
                                                                                    s.sort((a,b)=>a.length-b.length) // sort input by string length
                                                                                    .reduce( // reduce
                                                                                    (m,x,i)=>i%2?[...m,x]:[x,...m], // if index is even, stick string x at the end of the memo
                                                                                    // array, else at the beginning
                                                                                    // memo initialized to empty array
                                                                                    )





                                                                                    share|improve this answer









                                                                                    $endgroup$
















                                                                                      0












                                                                                      0








                                                                                      0





                                                                                      $begingroup$

                                                                                      Javascript 79 bytes



                                                                                      Takes input as an array of strings, outputs an arrow-sorted array of strings.



                                                                                      f=s=>s.sort((a,b)=>a.length-b.length).reduce((m,x,i)=>i%2?[...m,x]:[x,...m],)


                                                                                      Explanation



                                                                                      f = s =>                             // take input as an array of strings s
                                                                                      s.sort((a,b)=>a.length-b.length) // sort input by string length
                                                                                      .reduce( // reduce
                                                                                      (m,x,i)=>i%2?[...m,x]:[x,...m], // if index is even, stick string x at the end of the memo
                                                                                      // array, else at the beginning
                                                                                      // memo initialized to empty array
                                                                                      )





                                                                                      share|improve this answer









                                                                                      $endgroup$



                                                                                      Javascript 79 bytes



                                                                                      Takes input as an array of strings, outputs an arrow-sorted array of strings.



                                                                                      f=s=>s.sort((a,b)=>a.length-b.length).reduce((m,x,i)=>i%2?[...m,x]:[x,...m],)


                                                                                      Explanation



                                                                                      f = s =>                             // take input as an array of strings s
                                                                                      s.sort((a,b)=>a.length-b.length) // sort input by string length
                                                                                      .reduce( // reduce
                                                                                      (m,x,i)=>i%2?[...m,x]:[x,...m], // if index is even, stick string x at the end of the memo
                                                                                      // array, else at the beginning
                                                                                      // memo initialized to empty array
                                                                                      )






                                                                                      share|improve this answer












                                                                                      share|improve this answer



                                                                                      share|improve this answer










                                                                                      answered 10 hours ago









                                                                                      asgallantasgallant

                                                                                      1995




                                                                                      1995























                                                                                          0












                                                                                          $begingroup$


                                                                                          Retina, 26 bytes



                                                                                          N$`
                                                                                          $.&
                                                                                          *,2,^A`.+
                                                                                          ,2,G`.+


                                                                                          Try it online! Explanation:



                                                                                          N$`
                                                                                          $.&


                                                                                          Sort the lines in ascending order of length ($.& returns the length of the line).



                                                                                          *,2,^A`.+


                                                                                          Temporarily delete alternate lines and output the remaining lines in reverse order.



                                                                                          ,2,G`.+


                                                                                          Keep the only lines that were temporarily deleted and output them.






                                                                                          share|improve this answer









                                                                                          $endgroup$


















                                                                                            0












                                                                                            $begingroup$


                                                                                            Retina, 26 bytes



                                                                                            N$`
                                                                                            $.&
                                                                                            *,2,^A`.+
                                                                                            ,2,G`.+


                                                                                            Try it online! Explanation:



                                                                                            N$`
                                                                                            $.&


                                                                                            Sort the lines in ascending order of length ($.& returns the length of the line).



                                                                                            *,2,^A`.+


                                                                                            Temporarily delete alternate lines and output the remaining lines in reverse order.



                                                                                            ,2,G`.+


                                                                                            Keep the only lines that were temporarily deleted and output them.






                                                                                            share|improve this answer









                                                                                            $endgroup$
















                                                                                              0












                                                                                              0








                                                                                              0





                                                                                              $begingroup$


                                                                                              Retina, 26 bytes



                                                                                              N$`
                                                                                              $.&
                                                                                              *,2,^A`.+
                                                                                              ,2,G`.+


                                                                                              Try it online! Explanation:



                                                                                              N$`
                                                                                              $.&


                                                                                              Sort the lines in ascending order of length ($.& returns the length of the line).



                                                                                              *,2,^A`.+


                                                                                              Temporarily delete alternate lines and output the remaining lines in reverse order.



                                                                                              ,2,G`.+


                                                                                              Keep the only lines that were temporarily deleted and output them.






                                                                                              share|improve this answer









                                                                                              $endgroup$




                                                                                              Retina, 26 bytes



                                                                                              N$`
                                                                                              $.&
                                                                                              *,2,^A`.+
                                                                                              ,2,G`.+


                                                                                              Try it online! Explanation:



                                                                                              N$`
                                                                                              $.&


                                                                                              Sort the lines in ascending order of length ($.& returns the length of the line).



                                                                                              *,2,^A`.+


                                                                                              Temporarily delete alternate lines and output the remaining lines in reverse order.



                                                                                              ,2,G`.+


                                                                                              Keep the only lines that were temporarily deleted and output them.







                                                                                              share|improve this answer












                                                                                              share|improve this answer



                                                                                              share|improve this answer










                                                                                              answered 9 hours ago









                                                                                              NeilNeil

                                                                                              82.4k745179




                                                                                              82.4k745179























                                                                                                  0












                                                                                                  $begingroup$


                                                                                                  Gaia, 10 bytes



                                                                                                  el∫v:v+2%ụ


                                                                                                  Try it online!



                                                                                                  e		| eval as Gaia code (list of strings)
                                                                                                  l∫ | ∫ort by lengths (ascending)
                                                                                                  v:v | reverse, dup, reverse
                                                                                                  + | concatenate lists
                                                                                                  2% | take every other element
                                                                                                  ụ | join by newlines and output





                                                                                                  share|improve this answer









                                                                                                  $endgroup$









                                                                                                  • 1




                                                                                                    $begingroup$
                                                                                                    i like that your comments in unwrapped code form an arrow of strings
                                                                                                    $endgroup$
                                                                                                    – aaaaaa
                                                                                                    5 hours ago
















                                                                                                  0












                                                                                                  $begingroup$


                                                                                                  Gaia, 10 bytes



                                                                                                  el∫v:v+2%ụ


                                                                                                  Try it online!



                                                                                                  e		| eval as Gaia code (list of strings)
                                                                                                  l∫ | ∫ort by lengths (ascending)
                                                                                                  v:v | reverse, dup, reverse
                                                                                                  + | concatenate lists
                                                                                                  2% | take every other element
                                                                                                  ụ | join by newlines and output





                                                                                                  share|improve this answer









                                                                                                  $endgroup$









                                                                                                  • 1




                                                                                                    $begingroup$
                                                                                                    i like that your comments in unwrapped code form an arrow of strings
                                                                                                    $endgroup$
                                                                                                    – aaaaaa
                                                                                                    5 hours ago














                                                                                                  0












                                                                                                  0








                                                                                                  0





                                                                                                  $begingroup$


                                                                                                  Gaia, 10 bytes



                                                                                                  el∫v:v+2%ụ


                                                                                                  Try it online!



                                                                                                  e		| eval as Gaia code (list of strings)
                                                                                                  l∫ | ∫ort by lengths (ascending)
                                                                                                  v:v | reverse, dup, reverse
                                                                                                  + | concatenate lists
                                                                                                  2% | take every other element
                                                                                                  ụ | join by newlines and output





                                                                                                  share|improve this answer









                                                                                                  $endgroup$




                                                                                                  Gaia, 10 bytes



                                                                                                  el∫v:v+2%ụ


                                                                                                  Try it online!



                                                                                                  e		| eval as Gaia code (list of strings)
                                                                                                  l∫ | ∫ort by lengths (ascending)
                                                                                                  v:v | reverse, dup, reverse
                                                                                                  + | concatenate lists
                                                                                                  2% | take every other element
                                                                                                  ụ | join by newlines and output






                                                                                                  share|improve this answer












                                                                                                  share|improve this answer



                                                                                                  share|improve this answer










                                                                                                  answered 8 hours ago









                                                                                                  GiuseppeGiuseppe

                                                                                                  17.4k31152




                                                                                                  17.4k31152








                                                                                                  • 1




                                                                                                    $begingroup$
                                                                                                    i like that your comments in unwrapped code form an arrow of strings
                                                                                                    $endgroup$
                                                                                                    – aaaaaa
                                                                                                    5 hours ago














                                                                                                  • 1




                                                                                                    $begingroup$
                                                                                                    i like that your comments in unwrapped code form an arrow of strings
                                                                                                    $endgroup$
                                                                                                    – aaaaaa
                                                                                                    5 hours ago








                                                                                                  1




                                                                                                  1




                                                                                                  $begingroup$
                                                                                                  i like that your comments in unwrapped code form an arrow of strings
                                                                                                  $endgroup$
                                                                                                  – aaaaaa
                                                                                                  5 hours ago




                                                                                                  $begingroup$
                                                                                                  i like that your comments in unwrapped code form an arrow of strings
                                                                                                  $endgroup$
                                                                                                  – aaaaaa
                                                                                                  5 hours ago











                                                                                                  0












                                                                                                  $begingroup$


                                                                                                  C (gcc), 136 bytes





                                                                                                  S(a,b)char**a,**b;{a=strlen(*b)-strlen(*a);}f(l,s,o,t,i,b,e)char**s,**o,*t;{qsort(s,l,8,S);e=l-1;for(i=b=0;i-l;++i)o[i%2?b++:e--]=s[i];}


                                                                                                  Try it online!



                                                                                                  The function f is the solution. It takes the number of strings, the strings themselves, and the output buffer as arguments (plus four more used internally).






                                                                                                  share|improve this answer









                                                                                                  $endgroup$













                                                                                                  • $begingroup$
                                                                                                    Why is ./.bin.tio in the output?
                                                                                                    $endgroup$
                                                                                                    – Teleporting Goat
                                                                                                    7 hours ago










                                                                                                  • $begingroup$
                                                                                                    @TeleportingGoat Probably because their footer is using all of argv, which includes the filename
                                                                                                    $endgroup$
                                                                                                    – Jo King
                                                                                                    3 hours ago
















                                                                                                  0












                                                                                                  $begingroup$


                                                                                                  C (gcc), 136 bytes





                                                                                                  S(a,b)char**a,**b;{a=strlen(*b)-strlen(*a);}f(l,s,o,t,i,b,e)char**s,**o,*t;{qsort(s,l,8,S);e=l-1;for(i=b=0;i-l;++i)o[i%2?b++:e--]=s[i];}


                                                                                                  Try it online!



                                                                                                  The function f is the solution. It takes the number of strings, the strings themselves, and the output buffer as arguments (plus four more used internally).






                                                                                                  share|improve this answer









                                                                                                  $endgroup$













                                                                                                  • $begingroup$
                                                                                                    Why is ./.bin.tio in the output?
                                                                                                    $endgroup$
                                                                                                    – Teleporting Goat
                                                                                                    7 hours ago










                                                                                                  • $begingroup$
                                                                                                    @TeleportingGoat Probably because their footer is using all of argv, which includes the filename
                                                                                                    $endgroup$
                                                                                                    – Jo King
                                                                                                    3 hours ago














                                                                                                  0












                                                                                                  0








                                                                                                  0





                                                                                                  $begingroup$


                                                                                                  C (gcc), 136 bytes





                                                                                                  S(a,b)char**a,**b;{a=strlen(*b)-strlen(*a);}f(l,s,o,t,i,b,e)char**s,**o,*t;{qsort(s,l,8,S);e=l-1;for(i=b=0;i-l;++i)o[i%2?b++:e--]=s[i];}


                                                                                                  Try it online!



                                                                                                  The function f is the solution. It takes the number of strings, the strings themselves, and the output buffer as arguments (plus four more used internally).






                                                                                                  share|improve this answer









                                                                                                  $endgroup$




                                                                                                  C (gcc), 136 bytes





                                                                                                  S(a,b)char**a,**b;{a=strlen(*b)-strlen(*a);}f(l,s,o,t,i,b,e)char**s,**o,*t;{qsort(s,l,8,S);e=l-1;for(i=b=0;i-l;++i)o[i%2?b++:e--]=s[i];}


                                                                                                  Try it online!



                                                                                                  The function f is the solution. It takes the number of strings, the strings themselves, and the output buffer as arguments (plus four more used internally).







                                                                                                  share|improve this answer












                                                                                                  share|improve this answer



                                                                                                  share|improve this answer










                                                                                                  answered 7 hours ago









                                                                                                  LambdaBetaLambdaBeta

                                                                                                  2,129418




                                                                                                  2,129418












                                                                                                  • $begingroup$
                                                                                                    Why is ./.bin.tio in the output?
                                                                                                    $endgroup$
                                                                                                    – Teleporting Goat
                                                                                                    7 hours ago










                                                                                                  • $begingroup$
                                                                                                    @TeleportingGoat Probably because their footer is using all of argv, which includes the filename
                                                                                                    $endgroup$
                                                                                                    – Jo King
                                                                                                    3 hours ago


















                                                                                                  • $begingroup$
                                                                                                    Why is ./.bin.tio in the output?
                                                                                                    $endgroup$
                                                                                                    – Teleporting Goat
                                                                                                    7 hours ago










                                                                                                  • $begingroup$
                                                                                                    @TeleportingGoat Probably because their footer is using all of argv, which includes the filename
                                                                                                    $endgroup$
                                                                                                    – Jo King
                                                                                                    3 hours ago
















                                                                                                  $begingroup$
                                                                                                  Why is ./.bin.tio in the output?
                                                                                                  $endgroup$
                                                                                                  – Teleporting Goat
                                                                                                  7 hours ago




                                                                                                  $begingroup$
                                                                                                  Why is ./.bin.tio in the output?
                                                                                                  $endgroup$
                                                                                                  – Teleporting Goat
                                                                                                  7 hours ago












                                                                                                  $begingroup$
                                                                                                  @TeleportingGoat Probably because their footer is using all of argv, which includes the filename
                                                                                                  $endgroup$
                                                                                                  – Jo King
                                                                                                  3 hours ago




                                                                                                  $begingroup$
                                                                                                  @TeleportingGoat Probably because their footer is using all of argv, which includes the filename
                                                                                                  $endgroup$
                                                                                                  – Jo King
                                                                                                  3 hours ago











                                                                                                  0












                                                                                                  $begingroup$

                                                                                                  MATLAB, 92 bytes



                                                                                                  function f(y);[B,I]=sort(cellfun(@(x)length(x),y));disp({y{I(end:-2:1)},y{I(1:2:end)}}');end


                                                                                                  Takes input as cell array of strings, outputs column of strings (not sure if that's legal)



                                                                                                  > s = {'qweq qwe qw','qweqw','12132132131231231','asdasdasda','qwe','w'};
                                                                                                  > f(s);
                                                                                                  >
                                                                                                  > function f(y);[B,I]=sort(cellfun(@(x)length(x),y));disp({y{I(end:-2:1)},y{I(1:2:end)}}');end
                                                                                                  >
                                                                                                  > >>
                                                                                                  > '12132132131231231'
                                                                                                  > 'asdasdasda'
                                                                                                  > 'qwe'
                                                                                                  > 'w'
                                                                                                  > 'qweqw'
                                                                                                  > 'qweq qwe qw'





                                                                                                  share|improve this answer









                                                                                                  $endgroup$


















                                                                                                    0












                                                                                                    $begingroup$

                                                                                                    MATLAB, 92 bytes



                                                                                                    function f(y);[B,I]=sort(cellfun(@(x)length(x),y));disp({y{I(end:-2:1)},y{I(1:2:end)}}');end


                                                                                                    Takes input as cell array of strings, outputs column of strings (not sure if that's legal)



                                                                                                    > s = {'qweq qwe qw','qweqw','12132132131231231','asdasdasda','qwe','w'};
                                                                                                    > f(s);
                                                                                                    >
                                                                                                    > function f(y);[B,I]=sort(cellfun(@(x)length(x),y));disp({y{I(end:-2:1)},y{I(1:2:end)}}');end
                                                                                                    >
                                                                                                    > >>
                                                                                                    > '12132132131231231'
                                                                                                    > 'asdasdasda'
                                                                                                    > 'qwe'
                                                                                                    > 'w'
                                                                                                    > 'qweqw'
                                                                                                    > 'qweq qwe qw'





                                                                                                    share|improve this answer









                                                                                                    $endgroup$
















                                                                                                      0












                                                                                                      0








                                                                                                      0





                                                                                                      $begingroup$

                                                                                                      MATLAB, 92 bytes



                                                                                                      function f(y);[B,I]=sort(cellfun(@(x)length(x),y));disp({y{I(end:-2:1)},y{I(1:2:end)}}');end


                                                                                                      Takes input as cell array of strings, outputs column of strings (not sure if that's legal)



                                                                                                      > s = {'qweq qwe qw','qweqw','12132132131231231','asdasdasda','qwe','w'};
                                                                                                      > f(s);
                                                                                                      >
                                                                                                      > function f(y);[B,I]=sort(cellfun(@(x)length(x),y));disp({y{I(end:-2:1)},y{I(1:2:end)}}');end
                                                                                                      >
                                                                                                      > >>
                                                                                                      > '12132132131231231'
                                                                                                      > 'asdasdasda'
                                                                                                      > 'qwe'
                                                                                                      > 'w'
                                                                                                      > 'qweqw'
                                                                                                      > 'qweq qwe qw'





                                                                                                      share|improve this answer









                                                                                                      $endgroup$



                                                                                                      MATLAB, 92 bytes



                                                                                                      function f(y);[B,I]=sort(cellfun(@(x)length(x),y));disp({y{I(end:-2:1)},y{I(1:2:end)}}');end


                                                                                                      Takes input as cell array of strings, outputs column of strings (not sure if that's legal)



                                                                                                      > s = {'qweq qwe qw','qweqw','12132132131231231','asdasdasda','qwe','w'};
                                                                                                      > f(s);
                                                                                                      >
                                                                                                      > function f(y);[B,I]=sort(cellfun(@(x)length(x),y));disp({y{I(end:-2:1)},y{I(1:2:end)}}');end
                                                                                                      >
                                                                                                      > >>
                                                                                                      > '12132132131231231'
                                                                                                      > 'asdasdasda'
                                                                                                      > 'qwe'
                                                                                                      > 'w'
                                                                                                      > 'qweqw'
                                                                                                      > 'qweq qwe qw'






                                                                                                      share|improve this answer












                                                                                                      share|improve this answer



                                                                                                      share|improve this answer










                                                                                                      answered 5 hours ago









                                                                                                      aaaaaaaaaaaa

                                                                                                      3116




                                                                                                      3116























                                                                                                          0












                                                                                                          $begingroup$

                                                                                                          T-SQL, 99 bytes



                                                                                                          Input is a table



                                                                                                          DECLARE @ table(a varchar(80))
                                                                                                          INSERT @ values
                                                                                                          ('sheriffOfNottingham'),('kingRichard'),('maidMarian'),
                                                                                                          ('bow'),('arrows'),('princeJohn'),('sherwoodForest')

                                                                                                          SELECT a FROM(SELECT*,row_number()over(order by
                                                                                                          len(a))r,sum(1)over()c FROM @)x
                                                                                                          ORDER BY abs(c/2-r)


                                                                                                          Try it online






                                                                                                          share|improve this answer









                                                                                                          $endgroup$


















                                                                                                            0












                                                                                                            $begingroup$

                                                                                                            T-SQL, 99 bytes



                                                                                                            Input is a table



                                                                                                            DECLARE @ table(a varchar(80))
                                                                                                            INSERT @ values
                                                                                                            ('sheriffOfNottingham'),('kingRichard'),('maidMarian'),
                                                                                                            ('bow'),('arrows'),('princeJohn'),('sherwoodForest')

                                                                                                            SELECT a FROM(SELECT*,row_number()over(order by
                                                                                                            len(a))r,sum(1)over()c FROM @)x
                                                                                                            ORDER BY abs(c/2-r)


                                                                                                            Try it online






                                                                                                            share|improve this answer









                                                                                                            $endgroup$
















                                                                                                              0












                                                                                                              0








                                                                                                              0





                                                                                                              $begingroup$

                                                                                                              T-SQL, 99 bytes



                                                                                                              Input is a table



                                                                                                              DECLARE @ table(a varchar(80))
                                                                                                              INSERT @ values
                                                                                                              ('sheriffOfNottingham'),('kingRichard'),('maidMarian'),
                                                                                                              ('bow'),('arrows'),('princeJohn'),('sherwoodForest')

                                                                                                              SELECT a FROM(SELECT*,row_number()over(order by
                                                                                                              len(a))r,sum(1)over()c FROM @)x
                                                                                                              ORDER BY abs(c/2-r)


                                                                                                              Try it online






                                                                                                              share|improve this answer









                                                                                                              $endgroup$



                                                                                                              T-SQL, 99 bytes



                                                                                                              Input is a table



                                                                                                              DECLARE @ table(a varchar(80))
                                                                                                              INSERT @ values
                                                                                                              ('sheriffOfNottingham'),('kingRichard'),('maidMarian'),
                                                                                                              ('bow'),('arrows'),('princeJohn'),('sherwoodForest')

                                                                                                              SELECT a FROM(SELECT*,row_number()over(order by
                                                                                                              len(a))r,sum(1)over()c FROM @)x
                                                                                                              ORDER BY abs(c/2-r)


                                                                                                              Try it online







                                                                                                              share|improve this answer












                                                                                                              share|improve this answer



                                                                                                              share|improve this answer










                                                                                                              answered 16 mins ago









                                                                                                              t-clausen.dkt-clausen.dk

                                                                                                              2,054314




                                                                                                              2,054314























                                                                                                                  0












                                                                                                                  $begingroup$


                                                                                                                  PowerShell, 49 bytes





                                                                                                                  $args|sort l*|sort{$_.Length*($global:x=-$x*2+1)}


                                                                                                                  Try it online!



                                                                                                                  The double distillation.






                                                                                                                  share|improve this answer











                                                                                                                  $endgroup$


















                                                                                                                    0












                                                                                                                    $begingroup$


                                                                                                                    PowerShell, 49 bytes





                                                                                                                    $args|sort l*|sort{$_.Length*($global:x=-$x*2+1)}


                                                                                                                    Try it online!



                                                                                                                    The double distillation.






                                                                                                                    share|improve this answer











                                                                                                                    $endgroup$
















                                                                                                                      0












                                                                                                                      0








                                                                                                                      0





                                                                                                                      $begingroup$


                                                                                                                      PowerShell, 49 bytes





                                                                                                                      $args|sort l*|sort{$_.Length*($global:x=-$x*2+1)}


                                                                                                                      Try it online!



                                                                                                                      The double distillation.






                                                                                                                      share|improve this answer











                                                                                                                      $endgroup$




                                                                                                                      PowerShell, 49 bytes





                                                                                                                      $args|sort l*|sort{$_.Length*($global:x=-$x*2+1)}


                                                                                                                      Try it online!



                                                                                                                      The double distillation.







                                                                                                                      share|improve this answer














                                                                                                                      share|improve this answer



                                                                                                                      share|improve this answer








                                                                                                                      edited 16 mins ago

























                                                                                                                      answered 25 mins ago









                                                                                                                      mazzymazzy

                                                                                                                      2,9451317




                                                                                                                      2,9451317























                                                                                                                          -1












                                                                                                                          $begingroup$

                                                                                                                          Javascript 95 Bytes



                                                                                                                          s=>s.sort((x,y)=>x.length-y.length).reduce((a,e,i)=>{i%2?a.push(e):a.unshift(e);return a;},);





                                                                                                                          share|improve this answer










                                                                                                                          New contributor




                                                                                                                          somsom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                          Check out our Code of Conduct.






                                                                                                                          $endgroup$













                                                                                                                          • $begingroup$
                                                                                                                            -1 s.sort() sorts the strings lexicographically, not by string length.
                                                                                                                            $endgroup$
                                                                                                                            – asgallant
                                                                                                                            10 hours ago










                                                                                                                          • $begingroup$
                                                                                                                            Right, (x,y)=>x.length-y.length, should fix that.
                                                                                                                            $endgroup$
                                                                                                                            – somsom
                                                                                                                            10 hours ago
















                                                                                                                          -1












                                                                                                                          $begingroup$

                                                                                                                          Javascript 95 Bytes



                                                                                                                          s=>s.sort((x,y)=>x.length-y.length).reduce((a,e,i)=>{i%2?a.push(e):a.unshift(e);return a;},);





                                                                                                                          share|improve this answer










                                                                                                                          New contributor




                                                                                                                          somsom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                          Check out our Code of Conduct.






                                                                                                                          $endgroup$













                                                                                                                          • $begingroup$
                                                                                                                            -1 s.sort() sorts the strings lexicographically, not by string length.
                                                                                                                            $endgroup$
                                                                                                                            – asgallant
                                                                                                                            10 hours ago










                                                                                                                          • $begingroup$
                                                                                                                            Right, (x,y)=>x.length-y.length, should fix that.
                                                                                                                            $endgroup$
                                                                                                                            – somsom
                                                                                                                            10 hours ago














                                                                                                                          -1












                                                                                                                          -1








                                                                                                                          -1





                                                                                                                          $begingroup$

                                                                                                                          Javascript 95 Bytes



                                                                                                                          s=>s.sort((x,y)=>x.length-y.length).reduce((a,e,i)=>{i%2?a.push(e):a.unshift(e);return a;},);





                                                                                                                          share|improve this answer










                                                                                                                          New contributor




                                                                                                                          somsom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                          Check out our Code of Conduct.






                                                                                                                          $endgroup$



                                                                                                                          Javascript 95 Bytes



                                                                                                                          s=>s.sort((x,y)=>x.length-y.length).reduce((a,e,i)=>{i%2?a.push(e):a.unshift(e);return a;},);






                                                                                                                          share|improve this answer










                                                                                                                          New contributor




                                                                                                                          somsom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                          Check out our Code of Conduct.









                                                                                                                          share|improve this answer



                                                                                                                          share|improve this answer








                                                                                                                          edited 9 hours ago









                                                                                                                          Embodiment of Ignorance

                                                                                                                          2,358126




                                                                                                                          2,358126






                                                                                                                          New contributor




                                                                                                                          somsom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                          Check out our Code of Conduct.









                                                                                                                          answered 10 hours ago









                                                                                                                          somsomsomsom

                                                                                                                          11




                                                                                                                          11




                                                                                                                          New contributor




                                                                                                                          somsom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                          Check out our Code of Conduct.





                                                                                                                          New contributor





                                                                                                                          somsom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                          Check out our Code of Conduct.






                                                                                                                          somsom is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                                                                                                          Check out our Code of Conduct.












                                                                                                                          • $begingroup$
                                                                                                                            -1 s.sort() sorts the strings lexicographically, not by string length.
                                                                                                                            $endgroup$
                                                                                                                            – asgallant
                                                                                                                            10 hours ago










                                                                                                                          • $begingroup$
                                                                                                                            Right, (x,y)=>x.length-y.length, should fix that.
                                                                                                                            $endgroup$
                                                                                                                            – somsom
                                                                                                                            10 hours ago


















                                                                                                                          • $begingroup$
                                                                                                                            -1 s.sort() sorts the strings lexicographically, not by string length.
                                                                                                                            $endgroup$
                                                                                                                            – asgallant
                                                                                                                            10 hours ago










                                                                                                                          • $begingroup$
                                                                                                                            Right, (x,y)=>x.length-y.length, should fix that.
                                                                                                                            $endgroup$
                                                                                                                            – somsom
                                                                                                                            10 hours ago
















                                                                                                                          $begingroup$
                                                                                                                          -1 s.sort() sorts the strings lexicographically, not by string length.
                                                                                                                          $endgroup$
                                                                                                                          – asgallant
                                                                                                                          10 hours ago




                                                                                                                          $begingroup$
                                                                                                                          -1 s.sort() sorts the strings lexicographically, not by string length.
                                                                                                                          $endgroup$
                                                                                                                          – asgallant
                                                                                                                          10 hours ago












                                                                                                                          $begingroup$
                                                                                                                          Right, (x,y)=>x.length-y.length, should fix that.
                                                                                                                          $endgroup$
                                                                                                                          – somsom
                                                                                                                          10 hours ago




                                                                                                                          $begingroup$
                                                                                                                          Right, (x,y)=>x.length-y.length, should fix that.
                                                                                                                          $endgroup$
                                                                                                                          – somsom
                                                                                                                          10 hours ago










                                                                                                                          Teleporting Goat is a new contributor. Be nice, and check out our Code of Conduct.










                                                                                                                          draft saved

                                                                                                                          draft discarded


















                                                                                                                          Teleporting Goat is a new contributor. Be nice, and check out our Code of Conduct.













                                                                                                                          Teleporting Goat is a new contributor. Be nice, and check out our Code of Conduct.












                                                                                                                          Teleporting Goat is a new contributor. Be nice, and check out our Code of Conduct.
















                                                                                                                          If this is an answer to a challenge…




                                                                                                                          • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                          • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                            Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                          • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                                                          More generally…




                                                                                                                          • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                          • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                                                                                                          draft saved


                                                                                                                          draft discarded














                                                                                                                          StackExchange.ready(
                                                                                                                          function () {
                                                                                                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182615%2farrow-those-variables%23new-answer', 'question_page');
                                                                                                                          }
                                                                                                                          );

                                                                                                                          Post as a guest















                                                                                                                          Required, but never shown





















































                                                                                                                          Required, but never shown














                                                                                                                          Required, but never shown












                                                                                                                          Required, but never shown







                                                                                                                          Required, but never shown

































                                                                                                                          Required, but never shown














                                                                                                                          Required, but never shown












                                                                                                                          Required, but never shown







                                                                                                                          Required, but never shown







                                                                                                                          Popular posts from this blog

                                                                                                                          Contact image not getting when fetch all contact list from iPhone by CNContact

                                                                                                                          count number of partitions of a set with n elements into k subsets

                                                                                                                          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks