A quine of sortsTips for golfing in PythonOutput the first position in your program for each input characterWrite the shortest self-identifying program (a quine variant)Double-slit QuineQWERTY Quine CreationCheating Cyclic QuineGolf Me A Bubble SortIt's Anagram Quine, not just Quine!Solve an AnagramMake a lookup indexNumbers Increase While Letters DecreaseA “Sorting” algorithm

Can dual citizens open crypto exchange accounts where U.S. citizens are prohibited?

Why isn't UDP with reliability (implemented at Application layer) a substitute of TCP?

Who voices the character "Finger" in The Fifth Element?

What is the proper markup for a Math operator in boldface?

Why wasn't EBCDIC designed with contiguous alphanumeric characters?

A* pathfinding algorithm too slow

Is there a way to convert blue ice back into packed ice?

Translation of the Sator Square

If I have the War Caster feat, can I use the Thorn Whip cantrip to stop an enemy caster from escaping using the Dimension Door spell?

By RAW, how can Prestidigitation create sound?

Do home values typically rise and fall consistently across different price ranges?

How could an armless race establish civilization?

Ways to get SMD resistors from a strip

How did Lefschetz do mathematics without hands?

if a USA citizen marries a foreign citizen who has kid from previous marriage

How did they film the Invisible Man being invisible, in 1933?

On what to compliment someone with anorexia in order to improve their body image?

How do I present a future free of gender stereotypes without being jarring or overpowering the narrative?

Is it okay to fade a human face just to create some space to place important content over it?

Quantum jump/leap, exist or not, and instantaneous or not (for electrons)?

If two black hole event horizons overlap (touch) can they ever separate again?

Story where diplomats use codes for emotions

Adjective for 'made of pus' or 'corrupted by pus' or something of something of pus

Converting Geographic Coordinates into Lambert2008 coordinates



A quine of sorts


Tips for golfing in PythonOutput the first position in your program for each input characterWrite the shortest self-identifying program (a quine variant)Double-slit QuineQWERTY Quine CreationCheating Cyclic QuineGolf Me A Bubble SortIt's Anagram Quine, not just Quine!Solve an AnagramMake a lookup indexNumbers Increase While Letters DecreaseA “Sorting” algorithm






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








14












$begingroup$


Given a string x, output the characters in x sorted according to the order of appearance in your source code.



Examples



Source: ThisIs A Test
Input: Is it a Test?
Output: TissI etta?

Source: Harry - yer a wizard.
Input: I'm a what?
Output: aa wh'?Imt

Source: Mr. H. Potter, The Floor, Hut-on-the-Rock, The Sea
Input:
Output:


Rules



  • Standard loopholes & i/o rules apply

  • Input & output can be either a string, a list of characters, or a list of bytes.

  • If a character is used multiple times in the source, use the first occurrence.

  • If one or more characters does not appear in the source, they should be at the end; their order does not matter, nor does it have to be consistent.

  • Source must be non-empty

  • Newlines are treated the same as other characters.

  • The order in which the code is executed doesn't matter; just the raw string.

  • The input is in the same encoding as the code.

  • The input is sorted by characters, not by bytes.

  • This is code-golf, so shortest answer in bytes for each language wins!









share|improve this question







New contributor



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






$endgroup$











  • $begingroup$
    Do unprintable characters need to be accounted for? And if not, what about whitespace?
    $endgroup$
    – negative seven
    8 hours ago







  • 2




    $begingroup$
    @negativeseven Any characters from the source code encoding need to be accounted for, including whitespace.
    $endgroup$
    – tjjfvi
    8 hours ago










  • $begingroup$
    related
    $endgroup$
    – Rod
    6 hours ago










  • $begingroup$
    You should probably make explicit mention in the spec that matching is case sensitive.
    $endgroup$
    – Shaggy
    50 mins ago

















14












$begingroup$


Given a string x, output the characters in x sorted according to the order of appearance in your source code.



Examples



Source: ThisIs A Test
Input: Is it a Test?
Output: TissI etta?

Source: Harry - yer a wizard.
Input: I'm a what?
Output: aa wh'?Imt

Source: Mr. H. Potter, The Floor, Hut-on-the-Rock, The Sea
Input:
Output:


Rules



  • Standard loopholes & i/o rules apply

  • Input & output can be either a string, a list of characters, or a list of bytes.

  • If a character is used multiple times in the source, use the first occurrence.

  • If one or more characters does not appear in the source, they should be at the end; their order does not matter, nor does it have to be consistent.

  • Source must be non-empty

  • Newlines are treated the same as other characters.

  • The order in which the code is executed doesn't matter; just the raw string.

  • The input is in the same encoding as the code.

  • The input is sorted by characters, not by bytes.

  • This is code-golf, so shortest answer in bytes for each language wins!









share|improve this question







New contributor



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






$endgroup$











  • $begingroup$
    Do unprintable characters need to be accounted for? And if not, what about whitespace?
    $endgroup$
    – negative seven
    8 hours ago







  • 2




    $begingroup$
    @negativeseven Any characters from the source code encoding need to be accounted for, including whitespace.
    $endgroup$
    – tjjfvi
    8 hours ago










  • $begingroup$
    related
    $endgroup$
    – Rod
    6 hours ago










  • $begingroup$
    You should probably make explicit mention in the spec that matching is case sensitive.
    $endgroup$
    – Shaggy
    50 mins ago













14












14








14





$begingroup$


Given a string x, output the characters in x sorted according to the order of appearance in your source code.



Examples



Source: ThisIs A Test
Input: Is it a Test?
Output: TissI etta?

Source: Harry - yer a wizard.
Input: I'm a what?
Output: aa wh'?Imt

Source: Mr. H. Potter, The Floor, Hut-on-the-Rock, The Sea
Input:
Output:


Rules



  • Standard loopholes & i/o rules apply

  • Input & output can be either a string, a list of characters, or a list of bytes.

  • If a character is used multiple times in the source, use the first occurrence.

  • If one or more characters does not appear in the source, they should be at the end; their order does not matter, nor does it have to be consistent.

  • Source must be non-empty

  • Newlines are treated the same as other characters.

  • The order in which the code is executed doesn't matter; just the raw string.

  • The input is in the same encoding as the code.

  • The input is sorted by characters, not by bytes.

  • This is code-golf, so shortest answer in bytes for each language wins!









share|improve this question







New contributor



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






$endgroup$




Given a string x, output the characters in x sorted according to the order of appearance in your source code.



Examples



Source: ThisIs A Test
Input: Is it a Test?
Output: TissI etta?

Source: Harry - yer a wizard.
Input: I'm a what?
Output: aa wh'?Imt

Source: Mr. H. Potter, The Floor, Hut-on-the-Rock, The Sea
Input:
Output:


Rules



  • Standard loopholes & i/o rules apply

  • Input & output can be either a string, a list of characters, or a list of bytes.

  • If a character is used multiple times in the source, use the first occurrence.

  • If one or more characters does not appear in the source, they should be at the end; their order does not matter, nor does it have to be consistent.

  • Source must be non-empty

  • Newlines are treated the same as other characters.

  • The order in which the code is executed doesn't matter; just the raw string.

  • The input is in the same encoding as the code.

  • The input is sorted by characters, not by bytes.

  • This is code-golf, so shortest answer in bytes for each language wins!






code-golf quine sorting






share|improve this question







New contributor



tjjfvi 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



tjjfvi 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






New contributor



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








asked 9 hours ago









tjjfvitjjfvi

1417 bronze badges




1417 bronze badges




New contributor



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




New contributor




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













  • $begingroup$
    Do unprintable characters need to be accounted for? And if not, what about whitespace?
    $endgroup$
    – negative seven
    8 hours ago







  • 2




    $begingroup$
    @negativeseven Any characters from the source code encoding need to be accounted for, including whitespace.
    $endgroup$
    – tjjfvi
    8 hours ago










  • $begingroup$
    related
    $endgroup$
    – Rod
    6 hours ago










  • $begingroup$
    You should probably make explicit mention in the spec that matching is case sensitive.
    $endgroup$
    – Shaggy
    50 mins ago
















  • $begingroup$
    Do unprintable characters need to be accounted for? And if not, what about whitespace?
    $endgroup$
    – negative seven
    8 hours ago







  • 2




    $begingroup$
    @negativeseven Any characters from the source code encoding need to be accounted for, including whitespace.
    $endgroup$
    – tjjfvi
    8 hours ago










  • $begingroup$
    related
    $endgroup$
    – Rod
    6 hours ago










  • $begingroup$
    You should probably make explicit mention in the spec that matching is case sensitive.
    $endgroup$
    – Shaggy
    50 mins ago















$begingroup$
Do unprintable characters need to be accounted for? And if not, what about whitespace?
$endgroup$
– negative seven
8 hours ago





$begingroup$
Do unprintable characters need to be accounted for? And if not, what about whitespace?
$endgroup$
– negative seven
8 hours ago





2




2




$begingroup$
@negativeseven Any characters from the source code encoding need to be accounted for, including whitespace.
$endgroup$
– tjjfvi
8 hours ago




$begingroup$
@negativeseven Any characters from the source code encoding need to be accounted for, including whitespace.
$endgroup$
– tjjfvi
8 hours ago












$begingroup$
related
$endgroup$
– Rod
6 hours ago




$begingroup$
related
$endgroup$
– Rod
6 hours ago












$begingroup$
You should probably make explicit mention in the spec that matching is case sensitive.
$endgroup$
– Shaggy
50 mins ago




$begingroup$
You should probably make explicit mention in the spec that matching is case sensitive.
$endgroup$
– Shaggy
50 mins ago










9 Answers
9






active

oldest

votes


















4












$begingroup$


APL (Dyalog Unicode), 14 bytesSBCS





Anonymous tacit prefix function.



'''∘⍋⊃¨⊂'∘⍋⊃¨⊂


 enclose argument (to act on it as a whole)



⊃¨ from that, pick one character for each of the following indices:



∘⍋ the indices that would sort the argument in the the order given by the following string (all non-members go in order of appearance at the end):



'''∘⍋⊃¨⊂' the characters '∘⍋⊃¨⊂



Try it online!






share|improve this answer











$endgroup$




















    2












    $begingroup$


    J, 14 bytes



    Anonymous tacit prefix function.



    ]/:']/:''i'i:]


    Try it online!



    ] the argument



    i: last occurrence (non-members get the index beyond end of lookup string) of each character in:



    ']/:''i' the characters ]/:'i



    /: use that to sort:



    ] the argument






    share|improve this answer











    $endgroup$












    • $begingroup$
      Are the four leading spaces a result of the echo or the code?
      $endgroup$
      – tjjfvi
      7 hours ago






    • 1




      $begingroup$
      @tjjfvi It is how TIO is configured. Fixed now.
      $endgroup$
      – Adám
      7 hours ago


















    2












    $begingroup$


    05AB1E, 24 22 21 bytes



    Σ"Σ"'"«"'«Rrk}"«Rrk}R


    Try it online!



    Explanation:





    Σ } # Sort
    "Σ" # Σ string literal
    '" # " string literal
    « # Concatenate last two literals
    "'«Rrk}" # '«Rrk} another literal
    « # Concat again
    R # Reverse literal (so: }krR'«'"Σ)
    r # reverse stack
    k # find the current sorting index in our code string
    R # reverse our sorted string


    First time trying stuff in 05AB1E so probably lots to be saved






    share|improve this answer











    $endgroup$












    • $begingroup$
      Are you sure this is correct? The string it now sorts on is }krR«'«. NOTE: ' is a single character, so just '" is enough (unlike C# where it needs an additional trailing '). Currently your code first pushes the string Σ, then the string ", then the string «, then the string '«Rrk}, and then it does the append, reverse, reverse stack, index. Smart usage of the reverse of the string and at the end, though! I will see if I can find a fix for your answer, and will delete mine afterwards.
      $endgroup$
      – Kevin Cruijssen
      7 hours ago











    • $begingroup$
      @kevincruijssen So can't I just get rid of the second '
      $endgroup$
      – Expired Data
      7 hours ago






    • 1




      $begingroup$
      Yeah, you indeed can. :) Then it correctly sorts on }krR«'"Σ. PS: I tend to use = (print without popping) for debug purposes sometimes. You can also add --debug-stack as argument, but it's a bit weird in the new 05AB1E version imho.
      $endgroup$
      – Kevin Cruijssen
      7 hours ago


















    2












    $begingroup$


    Jelly, 14 bytes



    “;fɓḟṾⱮ”ṾɓfⱮ;ḟ


    A full program accepting a (Python formatted) string which prints the output.

    (as a monadic link it yields a list of lists of characters)



    Try it online!



    How?



    “;fɓḟṾⱮ”ṾɓfⱮ;ḟ - Main Link: list of characters, S
    “;fɓḟṾⱮ” - list of characters = [';', 'f', 'ɓ', 'ḟ', 'Ṿ', 'Ɱ']
    Ṿ - un-evaluate = ['“', ';', 'f', 'ɓ', 'ḟ', 'Ṿ', 'Ɱ', '”']
    ɓ - start a new dyadic chain, F(S, T=that):
    Ɱ - for each character, t, in T:
    f - (S) filter keep any of (the single character, t)
    ḟ - (S) filter discard any of (the characters in T)
    ; - concatenate





    share|improve this answer











    $endgroup$




















      2












      $begingroup$


      JavaScript (Node.js), 60 bytes





      f=_=>_.sort((a,b)=>(p=g=>-~`f=$f`.indexOf(g)||51)(a)-p(b))
      f= Function Name
      _=> Input _
      _.sort((a,b)=>( )(a)-p(b) Sort By
      p=g=>-~`f=$f`.indexOf(g)||70 Helper function which takes the index (in the function as string)
      of each char in the input, if it doesnt match any character
      then is assigned a value bigger than the max length of the function


      Try it online!






      share|improve this answer











      $endgroup$












      • $begingroup$
        Your code seems to only work when the source is f=.... If that is the case, please include that in your submission & byte count.
        $endgroup$
        – tjjfvi
        6 hours ago










      • $begingroup$
        search will fail if the input contains any RegEx characters (e.g., *), you'll need to use indexOf instead. Also, won't this fail overall if the length of the input is >50?
        $endgroup$
        – Shaggy
        6 hours ago










      • $begingroup$
        @Shaggy Thanks. I think now it gives the correct output in case of regex characters. Also the length of input doesnt matter in this sort since I just need to know the position of each character in my function, not the input
        $endgroup$
        – Luis felipe De jesus Munoz
        6 hours ago


















      2












      $begingroup$


      Jelly, 16 14 bytes



      “Ṿv`Ṿ;³³i@Þ”v`


      Try it online!



      A full program that takes a single argument, the string to be sorted.



      Thanks to @JonathanAllan for pointing out a bug!



      Explanation



      “Ṿv`Ṿ;³³i@Þ” | The string "Ṿv`Ṿ;³³i@Þ", referred to below as S
      v` | Evaluate this string as Jelly code using the string itself as the argument


      The string above evaluates as:



      Ṿ | Uneval the string S (effectively wraps it in “”)
      v` | Eval it (effectively removes the “”)
      Ṿ | Uneval it again, adding back in the “”
      ;³ | Concatenate the input to this
      ³i@Þ | Sort the input with respect to the first occurence of each character in the “”-wrapped string S concatenated to the input


      Ṿv` is a no-op effectively here, but exists to ensure all characters are represented.






      share|improve this answer











      $endgroup$




















        2












        $begingroup$


        Python 2, 102 100 96 85 79 76 68 bytes





        s="print sorted(input(),key=lambda x:('s=%r;c'%s+x).find(x))";exec s


        Try it online!



        -2 bytes by using this



        -4 bytes by realizing that <0 == ==-1 and removing the unnecessary +1



        -11 bytes thanks to Neil



        -6 bytes thanks to dzaima



        -3 bytes thanks to rod



        -8 bytes thanks to negative seven pointing out that the program can output a list of chars






        share|improve this answer











        $endgroup$












        • $begingroup$
          ('s=%r;exec(s)'%s+x).find(x)?
          $endgroup$
          – Neil
          7 hours ago










        • $begingroup$
          @Neil Is the current solution invalid, and substituting ('s=%r;exec(s)'%s).find(x) with your code would make it valid?
          $endgroup$
          – MilkyWay90
          7 hours ago










        • $begingroup$
          @Neil Oh, wait, I see your golf
          $endgroup$
          – MilkyWay90
          6 hours ago










        • $begingroup$
          79 bytes by shortening the inner string
          $endgroup$
          – dzaima
          6 hours ago










        • $begingroup$
          You can switch to input() and save 4 bytes
          $endgroup$
          – Rod
          6 hours ago


















        1












        $begingroup$


        Charcoal, 37 bytes



        ≔´≔´´´η´F´Φ´θ´⁼´ι´κ´¬´№ηFηΦθ⁼ικΦθ¬№ηι


        Try it online! Explanation:



        ≔´≔´´´η´F´Φ´θ´⁼´ι´κ´¬´№η


        There are two ways of quoting characters in Charcoal; ´ quotes any single character while ”y... quotes any character except and also counts as a separate string. It turns out that the overhead in having to deal with means that it doesn't end up any golfier.



        FηΦθ⁼ικ


        Loop over the characters in turn, outputting any matching characters from the input. This sorts the input.



        Φθ¬№ηι


        Output any unmatched characters in the input.






        share|improve this answer









        $endgroup$




















          1












          $begingroup$


          Ruby, 57 bytes





          ->ss.sort_byo


          Try it online!



          Fairly straightforward, assuming I haven't missed a golfing trick. Take in a list of characters and sort by their index in a string consisting of all the uniq characters in the code in order of their appearance. Often their first appearance is in that very string, but that doesn't change the order.






          share|improve this answer









          $endgroup$















            Your Answer






            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
            );



            );






            tjjfvi 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%2f187415%2fa-quine-of-sorts%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            9 Answers
            9






            active

            oldest

            votes








            9 Answers
            9






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4












            $begingroup$


            APL (Dyalog Unicode), 14 bytesSBCS





            Anonymous tacit prefix function.



            '''∘⍋⊃¨⊂'∘⍋⊃¨⊂


             enclose argument (to act on it as a whole)



            ⊃¨ from that, pick one character for each of the following indices:



            ∘⍋ the indices that would sort the argument in the the order given by the following string (all non-members go in order of appearance at the end):



            '''∘⍋⊃¨⊂' the characters '∘⍋⊃¨⊂



            Try it online!






            share|improve this answer











            $endgroup$

















              4












              $begingroup$


              APL (Dyalog Unicode), 14 bytesSBCS





              Anonymous tacit prefix function.



              '''∘⍋⊃¨⊂'∘⍋⊃¨⊂


               enclose argument (to act on it as a whole)



              ⊃¨ from that, pick one character for each of the following indices:



              ∘⍋ the indices that would sort the argument in the the order given by the following string (all non-members go in order of appearance at the end):



              '''∘⍋⊃¨⊂' the characters '∘⍋⊃¨⊂



              Try it online!






              share|improve this answer











              $endgroup$















                4












                4








                4





                $begingroup$


                APL (Dyalog Unicode), 14 bytesSBCS





                Anonymous tacit prefix function.



                '''∘⍋⊃¨⊂'∘⍋⊃¨⊂


                 enclose argument (to act on it as a whole)



                ⊃¨ from that, pick one character for each of the following indices:



                ∘⍋ the indices that would sort the argument in the the order given by the following string (all non-members go in order of appearance at the end):



                '''∘⍋⊃¨⊂' the characters '∘⍋⊃¨⊂



                Try it online!






                share|improve this answer











                $endgroup$




                APL (Dyalog Unicode), 14 bytesSBCS





                Anonymous tacit prefix function.



                '''∘⍋⊃¨⊂'∘⍋⊃¨⊂


                 enclose argument (to act on it as a whole)



                ⊃¨ from that, pick one character for each of the following indices:



                ∘⍋ the indices that would sort the argument in the the order given by the following string (all non-members go in order of appearance at the end):



                '''∘⍋⊃¨⊂' the characters '∘⍋⊃¨⊂



                Try it online!







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 6 hours ago

























                answered 9 hours ago









                AdámAdám

                28.1k2 gold badges79 silver badges210 bronze badges




                28.1k2 gold badges79 silver badges210 bronze badges























                    2












                    $begingroup$


                    J, 14 bytes



                    Anonymous tacit prefix function.



                    ]/:']/:''i'i:]


                    Try it online!



                    ] the argument



                    i: last occurrence (non-members get the index beyond end of lookup string) of each character in:



                    ']/:''i' the characters ]/:'i



                    /: use that to sort:



                    ] the argument






                    share|improve this answer











                    $endgroup$












                    • $begingroup$
                      Are the four leading spaces a result of the echo or the code?
                      $endgroup$
                      – tjjfvi
                      7 hours ago






                    • 1




                      $begingroup$
                      @tjjfvi It is how TIO is configured. Fixed now.
                      $endgroup$
                      – Adám
                      7 hours ago















                    2












                    $begingroup$


                    J, 14 bytes



                    Anonymous tacit prefix function.



                    ]/:']/:''i'i:]


                    Try it online!



                    ] the argument



                    i: last occurrence (non-members get the index beyond end of lookup string) of each character in:



                    ']/:''i' the characters ]/:'i



                    /: use that to sort:



                    ] the argument






                    share|improve this answer











                    $endgroup$












                    • $begingroup$
                      Are the four leading spaces a result of the echo or the code?
                      $endgroup$
                      – tjjfvi
                      7 hours ago






                    • 1




                      $begingroup$
                      @tjjfvi It is how TIO is configured. Fixed now.
                      $endgroup$
                      – Adám
                      7 hours ago













                    2












                    2








                    2





                    $begingroup$


                    J, 14 bytes



                    Anonymous tacit prefix function.



                    ]/:']/:''i'i:]


                    Try it online!



                    ] the argument



                    i: last occurrence (non-members get the index beyond end of lookup string) of each character in:



                    ']/:''i' the characters ]/:'i



                    /: use that to sort:



                    ] the argument






                    share|improve this answer











                    $endgroup$




                    J, 14 bytes



                    Anonymous tacit prefix function.



                    ]/:']/:''i'i:]


                    Try it online!



                    ] the argument



                    i: last occurrence (non-members get the index beyond end of lookup string) of each character in:



                    ']/:''i' the characters ]/:'i



                    /: use that to sort:



                    ] the argument







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 7 hours ago

























                    answered 8 hours ago









                    AdámAdám

                    28.1k2 gold badges79 silver badges210 bronze badges




                    28.1k2 gold badges79 silver badges210 bronze badges











                    • $begingroup$
                      Are the four leading spaces a result of the echo or the code?
                      $endgroup$
                      – tjjfvi
                      7 hours ago






                    • 1




                      $begingroup$
                      @tjjfvi It is how TIO is configured. Fixed now.
                      $endgroup$
                      – Adám
                      7 hours ago
















                    • $begingroup$
                      Are the four leading spaces a result of the echo or the code?
                      $endgroup$
                      – tjjfvi
                      7 hours ago






                    • 1




                      $begingroup$
                      @tjjfvi It is how TIO is configured. Fixed now.
                      $endgroup$
                      – Adám
                      7 hours ago















                    $begingroup$
                    Are the four leading spaces a result of the echo or the code?
                    $endgroup$
                    – tjjfvi
                    7 hours ago




                    $begingroup$
                    Are the four leading spaces a result of the echo or the code?
                    $endgroup$
                    – tjjfvi
                    7 hours ago




                    1




                    1




                    $begingroup$
                    @tjjfvi It is how TIO is configured. Fixed now.
                    $endgroup$
                    – Adám
                    7 hours ago




                    $begingroup$
                    @tjjfvi It is how TIO is configured. Fixed now.
                    $endgroup$
                    – Adám
                    7 hours ago











                    2












                    $begingroup$


                    05AB1E, 24 22 21 bytes



                    Σ"Σ"'"«"'«Rrk}"«Rrk}R


                    Try it online!



                    Explanation:





                    Σ } # Sort
                    "Σ" # Σ string literal
                    '" # " string literal
                    « # Concatenate last two literals
                    "'«Rrk}" # '«Rrk} another literal
                    « # Concat again
                    R # Reverse literal (so: }krR'«'"Σ)
                    r # reverse stack
                    k # find the current sorting index in our code string
                    R # reverse our sorted string


                    First time trying stuff in 05AB1E so probably lots to be saved






                    share|improve this answer











                    $endgroup$












                    • $begingroup$
                      Are you sure this is correct? The string it now sorts on is }krR«'«. NOTE: ' is a single character, so just '" is enough (unlike C# where it needs an additional trailing '). Currently your code first pushes the string Σ, then the string ", then the string «, then the string '«Rrk}, and then it does the append, reverse, reverse stack, index. Smart usage of the reverse of the string and at the end, though! I will see if I can find a fix for your answer, and will delete mine afterwards.
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago











                    • $begingroup$
                      @kevincruijssen So can't I just get rid of the second '
                      $endgroup$
                      – Expired Data
                      7 hours ago






                    • 1




                      $begingroup$
                      Yeah, you indeed can. :) Then it correctly sorts on }krR«'"Σ. PS: I tend to use = (print without popping) for debug purposes sometimes. You can also add --debug-stack as argument, but it's a bit weird in the new 05AB1E version imho.
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago















                    2












                    $begingroup$


                    05AB1E, 24 22 21 bytes



                    Σ"Σ"'"«"'«Rrk}"«Rrk}R


                    Try it online!



                    Explanation:





                    Σ } # Sort
                    "Σ" # Σ string literal
                    '" # " string literal
                    « # Concatenate last two literals
                    "'«Rrk}" # '«Rrk} another literal
                    « # Concat again
                    R # Reverse literal (so: }krR'«'"Σ)
                    r # reverse stack
                    k # find the current sorting index in our code string
                    R # reverse our sorted string


                    First time trying stuff in 05AB1E so probably lots to be saved






                    share|improve this answer











                    $endgroup$












                    • $begingroup$
                      Are you sure this is correct? The string it now sorts on is }krR«'«. NOTE: ' is a single character, so just '" is enough (unlike C# where it needs an additional trailing '). Currently your code first pushes the string Σ, then the string ", then the string «, then the string '«Rrk}, and then it does the append, reverse, reverse stack, index. Smart usage of the reverse of the string and at the end, though! I will see if I can find a fix for your answer, and will delete mine afterwards.
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago











                    • $begingroup$
                      @kevincruijssen So can't I just get rid of the second '
                      $endgroup$
                      – Expired Data
                      7 hours ago






                    • 1




                      $begingroup$
                      Yeah, you indeed can. :) Then it correctly sorts on }krR«'"Σ. PS: I tend to use = (print without popping) for debug purposes sometimes. You can also add --debug-stack as argument, but it's a bit weird in the new 05AB1E version imho.
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago













                    2












                    2








                    2





                    $begingroup$


                    05AB1E, 24 22 21 bytes



                    Σ"Σ"'"«"'«Rrk}"«Rrk}R


                    Try it online!



                    Explanation:





                    Σ } # Sort
                    "Σ" # Σ string literal
                    '" # " string literal
                    « # Concatenate last two literals
                    "'«Rrk}" # '«Rrk} another literal
                    « # Concat again
                    R # Reverse literal (so: }krR'«'"Σ)
                    r # reverse stack
                    k # find the current sorting index in our code string
                    R # reverse our sorted string


                    First time trying stuff in 05AB1E so probably lots to be saved






                    share|improve this answer











                    $endgroup$




                    05AB1E, 24 22 21 bytes



                    Σ"Σ"'"«"'«Rrk}"«Rrk}R


                    Try it online!



                    Explanation:





                    Σ } # Sort
                    "Σ" # Σ string literal
                    '" # " string literal
                    « # Concatenate last two literals
                    "'«Rrk}" # '«Rrk} another literal
                    « # Concat again
                    R # Reverse literal (so: }krR'«'"Σ)
                    r # reverse stack
                    k # find the current sorting index in our code string
                    R # reverse our sorted string


                    First time trying stuff in 05AB1E so probably lots to be saved







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 7 hours ago

























                    answered 8 hours ago









                    Expired DataExpired Data

                    1,3934 silver badges18 bronze badges




                    1,3934 silver badges18 bronze badges











                    • $begingroup$
                      Are you sure this is correct? The string it now sorts on is }krR«'«. NOTE: ' is a single character, so just '" is enough (unlike C# where it needs an additional trailing '). Currently your code first pushes the string Σ, then the string ", then the string «, then the string '«Rrk}, and then it does the append, reverse, reverse stack, index. Smart usage of the reverse of the string and at the end, though! I will see if I can find a fix for your answer, and will delete mine afterwards.
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago











                    • $begingroup$
                      @kevincruijssen So can't I just get rid of the second '
                      $endgroup$
                      – Expired Data
                      7 hours ago






                    • 1




                      $begingroup$
                      Yeah, you indeed can. :) Then it correctly sorts on }krR«'"Σ. PS: I tend to use = (print without popping) for debug purposes sometimes. You can also add --debug-stack as argument, but it's a bit weird in the new 05AB1E version imho.
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago
















                    • $begingroup$
                      Are you sure this is correct? The string it now sorts on is }krR«'«. NOTE: ' is a single character, so just '" is enough (unlike C# where it needs an additional trailing '). Currently your code first pushes the string Σ, then the string ", then the string «, then the string '«Rrk}, and then it does the append, reverse, reverse stack, index. Smart usage of the reverse of the string and at the end, though! I will see if I can find a fix for your answer, and will delete mine afterwards.
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago











                    • $begingroup$
                      @kevincruijssen So can't I just get rid of the second '
                      $endgroup$
                      – Expired Data
                      7 hours ago






                    • 1




                      $begingroup$
                      Yeah, you indeed can. :) Then it correctly sorts on }krR«'"Σ. PS: I tend to use = (print without popping) for debug purposes sometimes. You can also add --debug-stack as argument, but it's a bit weird in the new 05AB1E version imho.
                      $endgroup$
                      – Kevin Cruijssen
                      7 hours ago















                    $begingroup$
                    Are you sure this is correct? The string it now sorts on is }krR«'«. NOTE: ' is a single character, so just '" is enough (unlike C# where it needs an additional trailing '). Currently your code first pushes the string Σ, then the string ", then the string «, then the string '«Rrk}, and then it does the append, reverse, reverse stack, index. Smart usage of the reverse of the string and at the end, though! I will see if I can find a fix for your answer, and will delete mine afterwards.
                    $endgroup$
                    – Kevin Cruijssen
                    7 hours ago





                    $begingroup$
                    Are you sure this is correct? The string it now sorts on is }krR«'«. NOTE: ' is a single character, so just '" is enough (unlike C# where it needs an additional trailing '). Currently your code first pushes the string Σ, then the string ", then the string «, then the string '«Rrk}, and then it does the append, reverse, reverse stack, index. Smart usage of the reverse of the string and at the end, though! I will see if I can find a fix for your answer, and will delete mine afterwards.
                    $endgroup$
                    – Kevin Cruijssen
                    7 hours ago













                    $begingroup$
                    @kevincruijssen So can't I just get rid of the second '
                    $endgroup$
                    – Expired Data
                    7 hours ago




                    $begingroup$
                    @kevincruijssen So can't I just get rid of the second '
                    $endgroup$
                    – Expired Data
                    7 hours ago




                    1




                    1




                    $begingroup$
                    Yeah, you indeed can. :) Then it correctly sorts on }krR«'"Σ. PS: I tend to use = (print without popping) for debug purposes sometimes. You can also add --debug-stack as argument, but it's a bit weird in the new 05AB1E version imho.
                    $endgroup$
                    – Kevin Cruijssen
                    7 hours ago




                    $begingroup$
                    Yeah, you indeed can. :) Then it correctly sorts on }krR«'"Σ. PS: I tend to use = (print without popping) for debug purposes sometimes. You can also add --debug-stack as argument, but it's a bit weird in the new 05AB1E version imho.
                    $endgroup$
                    – Kevin Cruijssen
                    7 hours ago











                    2












                    $begingroup$


                    Jelly, 14 bytes



                    “;fɓḟṾⱮ”ṾɓfⱮ;ḟ


                    A full program accepting a (Python formatted) string which prints the output.

                    (as a monadic link it yields a list of lists of characters)



                    Try it online!



                    How?



                    “;fɓḟṾⱮ”ṾɓfⱮ;ḟ - Main Link: list of characters, S
                    “;fɓḟṾⱮ” - list of characters = [';', 'f', 'ɓ', 'ḟ', 'Ṿ', 'Ɱ']
                    Ṿ - un-evaluate = ['“', ';', 'f', 'ɓ', 'ḟ', 'Ṿ', 'Ɱ', '”']
                    ɓ - start a new dyadic chain, F(S, T=that):
                    Ɱ - for each character, t, in T:
                    f - (S) filter keep any of (the single character, t)
                    ḟ - (S) filter discard any of (the characters in T)
                    ; - concatenate





                    share|improve this answer











                    $endgroup$

















                      2












                      $begingroup$


                      Jelly, 14 bytes



                      “;fɓḟṾⱮ”ṾɓfⱮ;ḟ


                      A full program accepting a (Python formatted) string which prints the output.

                      (as a monadic link it yields a list of lists of characters)



                      Try it online!



                      How?



                      “;fɓḟṾⱮ”ṾɓfⱮ;ḟ - Main Link: list of characters, S
                      “;fɓḟṾⱮ” - list of characters = [';', 'f', 'ɓ', 'ḟ', 'Ṿ', 'Ɱ']
                      Ṿ - un-evaluate = ['“', ';', 'f', 'ɓ', 'ḟ', 'Ṿ', 'Ɱ', '”']
                      ɓ - start a new dyadic chain, F(S, T=that):
                      Ɱ - for each character, t, in T:
                      f - (S) filter keep any of (the single character, t)
                      ḟ - (S) filter discard any of (the characters in T)
                      ; - concatenate





                      share|improve this answer











                      $endgroup$















                        2












                        2








                        2





                        $begingroup$


                        Jelly, 14 bytes



                        “;fɓḟṾⱮ”ṾɓfⱮ;ḟ


                        A full program accepting a (Python formatted) string which prints the output.

                        (as a monadic link it yields a list of lists of characters)



                        Try it online!



                        How?



                        “;fɓḟṾⱮ”ṾɓfⱮ;ḟ - Main Link: list of characters, S
                        “;fɓḟṾⱮ” - list of characters = [';', 'f', 'ɓ', 'ḟ', 'Ṿ', 'Ɱ']
                        Ṿ - un-evaluate = ['“', ';', 'f', 'ɓ', 'ḟ', 'Ṿ', 'Ɱ', '”']
                        ɓ - start a new dyadic chain, F(S, T=that):
                        Ɱ - for each character, t, in T:
                        f - (S) filter keep any of (the single character, t)
                        ḟ - (S) filter discard any of (the characters in T)
                        ; - concatenate





                        share|improve this answer











                        $endgroup$




                        Jelly, 14 bytes



                        “;fɓḟṾⱮ”ṾɓfⱮ;ḟ


                        A full program accepting a (Python formatted) string which prints the output.

                        (as a monadic link it yields a list of lists of characters)



                        Try it online!



                        How?



                        “;fɓḟṾⱮ”ṾɓfⱮ;ḟ - Main Link: list of characters, S
                        “;fɓḟṾⱮ” - list of characters = [';', 'f', 'ɓ', 'ḟ', 'Ṿ', 'Ɱ']
                        Ṿ - un-evaluate = ['“', ';', 'f', 'ɓ', 'ḟ', 'Ṿ', 'Ɱ', '”']
                        ɓ - start a new dyadic chain, F(S, T=that):
                        Ɱ - for each character, t, in T:
                        f - (S) filter keep any of (the single character, t)
                        ḟ - (S) filter discard any of (the characters in T)
                        ; - concatenate






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited 5 hours ago

























                        answered 5 hours ago









                        Jonathan AllanJonathan Allan

                        56.5k5 gold badges41 silver badges178 bronze badges




                        56.5k5 gold badges41 silver badges178 bronze badges





















                            2












                            $begingroup$


                            JavaScript (Node.js), 60 bytes





                            f=_=>_.sort((a,b)=>(p=g=>-~`f=$f`.indexOf(g)||51)(a)-p(b))
                            f= Function Name
                            _=> Input _
                            _.sort((a,b)=>( )(a)-p(b) Sort By
                            p=g=>-~`f=$f`.indexOf(g)||70 Helper function which takes the index (in the function as string)
                            of each char in the input, if it doesnt match any character
                            then is assigned a value bigger than the max length of the function


                            Try it online!






                            share|improve this answer











                            $endgroup$












                            • $begingroup$
                              Your code seems to only work when the source is f=.... If that is the case, please include that in your submission & byte count.
                              $endgroup$
                              – tjjfvi
                              6 hours ago










                            • $begingroup$
                              search will fail if the input contains any RegEx characters (e.g., *), you'll need to use indexOf instead. Also, won't this fail overall if the length of the input is >50?
                              $endgroup$
                              – Shaggy
                              6 hours ago










                            • $begingroup$
                              @Shaggy Thanks. I think now it gives the correct output in case of regex characters. Also the length of input doesnt matter in this sort since I just need to know the position of each character in my function, not the input
                              $endgroup$
                              – Luis felipe De jesus Munoz
                              6 hours ago















                            2












                            $begingroup$


                            JavaScript (Node.js), 60 bytes





                            f=_=>_.sort((a,b)=>(p=g=>-~`f=$f`.indexOf(g)||51)(a)-p(b))
                            f= Function Name
                            _=> Input _
                            _.sort((a,b)=>( )(a)-p(b) Sort By
                            p=g=>-~`f=$f`.indexOf(g)||70 Helper function which takes the index (in the function as string)
                            of each char in the input, if it doesnt match any character
                            then is assigned a value bigger than the max length of the function


                            Try it online!






                            share|improve this answer











                            $endgroup$












                            • $begingroup$
                              Your code seems to only work when the source is f=.... If that is the case, please include that in your submission & byte count.
                              $endgroup$
                              – tjjfvi
                              6 hours ago










                            • $begingroup$
                              search will fail if the input contains any RegEx characters (e.g., *), you'll need to use indexOf instead. Also, won't this fail overall if the length of the input is >50?
                              $endgroup$
                              – Shaggy
                              6 hours ago










                            • $begingroup$
                              @Shaggy Thanks. I think now it gives the correct output in case of regex characters. Also the length of input doesnt matter in this sort since I just need to know the position of each character in my function, not the input
                              $endgroup$
                              – Luis felipe De jesus Munoz
                              6 hours ago













                            2












                            2








                            2





                            $begingroup$


                            JavaScript (Node.js), 60 bytes





                            f=_=>_.sort((a,b)=>(p=g=>-~`f=$f`.indexOf(g)||51)(a)-p(b))
                            f= Function Name
                            _=> Input _
                            _.sort((a,b)=>( )(a)-p(b) Sort By
                            p=g=>-~`f=$f`.indexOf(g)||70 Helper function which takes the index (in the function as string)
                            of each char in the input, if it doesnt match any character
                            then is assigned a value bigger than the max length of the function


                            Try it online!






                            share|improve this answer











                            $endgroup$




                            JavaScript (Node.js), 60 bytes





                            f=_=>_.sort((a,b)=>(p=g=>-~`f=$f`.indexOf(g)||51)(a)-p(b))
                            f= Function Name
                            _=> Input _
                            _.sort((a,b)=>( )(a)-p(b) Sort By
                            p=g=>-~`f=$f`.indexOf(g)||70 Helper function which takes the index (in the function as string)
                            of each char in the input, if it doesnt match any character
                            then is assigned a value bigger than the max length of the function


                            Try it online!







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 5 hours ago

























                            answered 7 hours ago









                            Luis felipe De jesus MunozLuis felipe De jesus Munoz

                            6,3862 gold badges18 silver badges74 bronze badges




                            6,3862 gold badges18 silver badges74 bronze badges











                            • $begingroup$
                              Your code seems to only work when the source is f=.... If that is the case, please include that in your submission & byte count.
                              $endgroup$
                              – tjjfvi
                              6 hours ago










                            • $begingroup$
                              search will fail if the input contains any RegEx characters (e.g., *), you'll need to use indexOf instead. Also, won't this fail overall if the length of the input is >50?
                              $endgroup$
                              – Shaggy
                              6 hours ago










                            • $begingroup$
                              @Shaggy Thanks. I think now it gives the correct output in case of regex characters. Also the length of input doesnt matter in this sort since I just need to know the position of each character in my function, not the input
                              $endgroup$
                              – Luis felipe De jesus Munoz
                              6 hours ago
















                            • $begingroup$
                              Your code seems to only work when the source is f=.... If that is the case, please include that in your submission & byte count.
                              $endgroup$
                              – tjjfvi
                              6 hours ago










                            • $begingroup$
                              search will fail if the input contains any RegEx characters (e.g., *), you'll need to use indexOf instead. Also, won't this fail overall if the length of the input is >50?
                              $endgroup$
                              – Shaggy
                              6 hours ago










                            • $begingroup$
                              @Shaggy Thanks. I think now it gives the correct output in case of regex characters. Also the length of input doesnt matter in this sort since I just need to know the position of each character in my function, not the input
                              $endgroup$
                              – Luis felipe De jesus Munoz
                              6 hours ago















                            $begingroup$
                            Your code seems to only work when the source is f=.... If that is the case, please include that in your submission & byte count.
                            $endgroup$
                            – tjjfvi
                            6 hours ago




                            $begingroup$
                            Your code seems to only work when the source is f=.... If that is the case, please include that in your submission & byte count.
                            $endgroup$
                            – tjjfvi
                            6 hours ago












                            $begingroup$
                            search will fail if the input contains any RegEx characters (e.g., *), you'll need to use indexOf instead. Also, won't this fail overall if the length of the input is >50?
                            $endgroup$
                            – Shaggy
                            6 hours ago




                            $begingroup$
                            search will fail if the input contains any RegEx characters (e.g., *), you'll need to use indexOf instead. Also, won't this fail overall if the length of the input is >50?
                            $endgroup$
                            – Shaggy
                            6 hours ago












                            $begingroup$
                            @Shaggy Thanks. I think now it gives the correct output in case of regex characters. Also the length of input doesnt matter in this sort since I just need to know the position of each character in my function, not the input
                            $endgroup$
                            – Luis felipe De jesus Munoz
                            6 hours ago




                            $begingroup$
                            @Shaggy Thanks. I think now it gives the correct output in case of regex characters. Also the length of input doesnt matter in this sort since I just need to know the position of each character in my function, not the input
                            $endgroup$
                            – Luis felipe De jesus Munoz
                            6 hours ago











                            2












                            $begingroup$


                            Jelly, 16 14 bytes



                            “Ṿv`Ṿ;³³i@Þ”v`


                            Try it online!



                            A full program that takes a single argument, the string to be sorted.



                            Thanks to @JonathanAllan for pointing out a bug!



                            Explanation



                            “Ṿv`Ṿ;³³i@Þ” | The string "Ṿv`Ṿ;³³i@Þ", referred to below as S
                            v` | Evaluate this string as Jelly code using the string itself as the argument


                            The string above evaluates as:



                            Ṿ | Uneval the string S (effectively wraps it in “”)
                            v` | Eval it (effectively removes the “”)
                            Ṿ | Uneval it again, adding back in the “”
                            ;³ | Concatenate the input to this
                            ³i@Þ | Sort the input with respect to the first occurence of each character in the “”-wrapped string S concatenated to the input


                            Ṿv` is a no-op effectively here, but exists to ensure all characters are represented.






                            share|improve this answer











                            $endgroup$

















                              2












                              $begingroup$


                              Jelly, 16 14 bytes



                              “Ṿv`Ṿ;³³i@Þ”v`


                              Try it online!



                              A full program that takes a single argument, the string to be sorted.



                              Thanks to @JonathanAllan for pointing out a bug!



                              Explanation



                              “Ṿv`Ṿ;³³i@Þ” | The string "Ṿv`Ṿ;³³i@Þ", referred to below as S
                              v` | Evaluate this string as Jelly code using the string itself as the argument


                              The string above evaluates as:



                              Ṿ | Uneval the string S (effectively wraps it in “”)
                              v` | Eval it (effectively removes the “”)
                              Ṿ | Uneval it again, adding back in the “”
                              ;³ | Concatenate the input to this
                              ³i@Þ | Sort the input with respect to the first occurence of each character in the “”-wrapped string S concatenated to the input


                              Ṿv` is a no-op effectively here, but exists to ensure all characters are represented.






                              share|improve this answer











                              $endgroup$















                                2












                                2








                                2





                                $begingroup$


                                Jelly, 16 14 bytes



                                “Ṿv`Ṿ;³³i@Þ”v`


                                Try it online!



                                A full program that takes a single argument, the string to be sorted.



                                Thanks to @JonathanAllan for pointing out a bug!



                                Explanation



                                “Ṿv`Ṿ;³³i@Þ” | The string "Ṿv`Ṿ;³³i@Þ", referred to below as S
                                v` | Evaluate this string as Jelly code using the string itself as the argument


                                The string above evaluates as:



                                Ṿ | Uneval the string S (effectively wraps it in “”)
                                v` | Eval it (effectively removes the “”)
                                Ṿ | Uneval it again, adding back in the “”
                                ;³ | Concatenate the input to this
                                ³i@Þ | Sort the input with respect to the first occurence of each character in the “”-wrapped string S concatenated to the input


                                Ṿv` is a no-op effectively here, but exists to ensure all characters are represented.






                                share|improve this answer











                                $endgroup$




                                Jelly, 16 14 bytes



                                “Ṿv`Ṿ;³³i@Þ”v`


                                Try it online!



                                A full program that takes a single argument, the string to be sorted.



                                Thanks to @JonathanAllan for pointing out a bug!



                                Explanation



                                “Ṿv`Ṿ;³³i@Þ” | The string "Ṿv`Ṿ;³³i@Þ", referred to below as S
                                v` | Evaluate this string as Jelly code using the string itself as the argument


                                The string above evaluates as:



                                Ṿ | Uneval the string S (effectively wraps it in “”)
                                v` | Eval it (effectively removes the “”)
                                Ṿ | Uneval it again, adding back in the “”
                                ;³ | Concatenate the input to this
                                ³i@Þ | Sort the input with respect to the first occurence of each character in the “”-wrapped string S concatenated to the input


                                Ṿv` is a no-op effectively here, but exists to ensure all characters are represented.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited 4 hours ago

























                                answered 8 hours ago









                                Nick KennedyNick Kennedy

                                3,8747 silver badges12 bronze badges




                                3,8747 silver badges12 bronze badges





















                                    2












                                    $begingroup$


                                    Python 2, 102 100 96 85 79 76 68 bytes





                                    s="print sorted(input(),key=lambda x:('s=%r;c'%s+x).find(x))";exec s


                                    Try it online!



                                    -2 bytes by using this



                                    -4 bytes by realizing that <0 == ==-1 and removing the unnecessary +1



                                    -11 bytes thanks to Neil



                                    -6 bytes thanks to dzaima



                                    -3 bytes thanks to rod



                                    -8 bytes thanks to negative seven pointing out that the program can output a list of chars






                                    share|improve this answer











                                    $endgroup$












                                    • $begingroup$
                                      ('s=%r;exec(s)'%s+x).find(x)?
                                      $endgroup$
                                      – Neil
                                      7 hours ago










                                    • $begingroup$
                                      @Neil Is the current solution invalid, and substituting ('s=%r;exec(s)'%s).find(x) with your code would make it valid?
                                      $endgroup$
                                      – MilkyWay90
                                      7 hours ago










                                    • $begingroup$
                                      @Neil Oh, wait, I see your golf
                                      $endgroup$
                                      – MilkyWay90
                                      6 hours ago










                                    • $begingroup$
                                      79 bytes by shortening the inner string
                                      $endgroup$
                                      – dzaima
                                      6 hours ago










                                    • $begingroup$
                                      You can switch to input() and save 4 bytes
                                      $endgroup$
                                      – Rod
                                      6 hours ago















                                    2












                                    $begingroup$


                                    Python 2, 102 100 96 85 79 76 68 bytes





                                    s="print sorted(input(),key=lambda x:('s=%r;c'%s+x).find(x))";exec s


                                    Try it online!



                                    -2 bytes by using this



                                    -4 bytes by realizing that <0 == ==-1 and removing the unnecessary +1



                                    -11 bytes thanks to Neil



                                    -6 bytes thanks to dzaima



                                    -3 bytes thanks to rod



                                    -8 bytes thanks to negative seven pointing out that the program can output a list of chars






                                    share|improve this answer











                                    $endgroup$












                                    • $begingroup$
                                      ('s=%r;exec(s)'%s+x).find(x)?
                                      $endgroup$
                                      – Neil
                                      7 hours ago










                                    • $begingroup$
                                      @Neil Is the current solution invalid, and substituting ('s=%r;exec(s)'%s).find(x) with your code would make it valid?
                                      $endgroup$
                                      – MilkyWay90
                                      7 hours ago










                                    • $begingroup$
                                      @Neil Oh, wait, I see your golf
                                      $endgroup$
                                      – MilkyWay90
                                      6 hours ago










                                    • $begingroup$
                                      79 bytes by shortening the inner string
                                      $endgroup$
                                      – dzaima
                                      6 hours ago










                                    • $begingroup$
                                      You can switch to input() and save 4 bytes
                                      $endgroup$
                                      – Rod
                                      6 hours ago













                                    2












                                    2








                                    2





                                    $begingroup$


                                    Python 2, 102 100 96 85 79 76 68 bytes





                                    s="print sorted(input(),key=lambda x:('s=%r;c'%s+x).find(x))";exec s


                                    Try it online!



                                    -2 bytes by using this



                                    -4 bytes by realizing that <0 == ==-1 and removing the unnecessary +1



                                    -11 bytes thanks to Neil



                                    -6 bytes thanks to dzaima



                                    -3 bytes thanks to rod



                                    -8 bytes thanks to negative seven pointing out that the program can output a list of chars






                                    share|improve this answer











                                    $endgroup$




                                    Python 2, 102 100 96 85 79 76 68 bytes





                                    s="print sorted(input(),key=lambda x:('s=%r;c'%s+x).find(x))";exec s


                                    Try it online!



                                    -2 bytes by using this



                                    -4 bytes by realizing that <0 == ==-1 and removing the unnecessary +1



                                    -11 bytes thanks to Neil



                                    -6 bytes thanks to dzaima



                                    -3 bytes thanks to rod



                                    -8 bytes thanks to negative seven pointing out that the program can output a list of chars







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 3 hours ago

























                                    answered 7 hours ago









                                    MilkyWay90MilkyWay90

                                    1,0533 silver badges23 bronze badges




                                    1,0533 silver badges23 bronze badges











                                    • $begingroup$
                                      ('s=%r;exec(s)'%s+x).find(x)?
                                      $endgroup$
                                      – Neil
                                      7 hours ago










                                    • $begingroup$
                                      @Neil Is the current solution invalid, and substituting ('s=%r;exec(s)'%s).find(x) with your code would make it valid?
                                      $endgroup$
                                      – MilkyWay90
                                      7 hours ago










                                    • $begingroup$
                                      @Neil Oh, wait, I see your golf
                                      $endgroup$
                                      – MilkyWay90
                                      6 hours ago










                                    • $begingroup$
                                      79 bytes by shortening the inner string
                                      $endgroup$
                                      – dzaima
                                      6 hours ago










                                    • $begingroup$
                                      You can switch to input() and save 4 bytes
                                      $endgroup$
                                      – Rod
                                      6 hours ago
















                                    • $begingroup$
                                      ('s=%r;exec(s)'%s+x).find(x)?
                                      $endgroup$
                                      – Neil
                                      7 hours ago










                                    • $begingroup$
                                      @Neil Is the current solution invalid, and substituting ('s=%r;exec(s)'%s).find(x) with your code would make it valid?
                                      $endgroup$
                                      – MilkyWay90
                                      7 hours ago










                                    • $begingroup$
                                      @Neil Oh, wait, I see your golf
                                      $endgroup$
                                      – MilkyWay90
                                      6 hours ago










                                    • $begingroup$
                                      79 bytes by shortening the inner string
                                      $endgroup$
                                      – dzaima
                                      6 hours ago










                                    • $begingroup$
                                      You can switch to input() and save 4 bytes
                                      $endgroup$
                                      – Rod
                                      6 hours ago















                                    $begingroup$
                                    ('s=%r;exec(s)'%s+x).find(x)?
                                    $endgroup$
                                    – Neil
                                    7 hours ago




                                    $begingroup$
                                    ('s=%r;exec(s)'%s+x).find(x)?
                                    $endgroup$
                                    – Neil
                                    7 hours ago












                                    $begingroup$
                                    @Neil Is the current solution invalid, and substituting ('s=%r;exec(s)'%s).find(x) with your code would make it valid?
                                    $endgroup$
                                    – MilkyWay90
                                    7 hours ago




                                    $begingroup$
                                    @Neil Is the current solution invalid, and substituting ('s=%r;exec(s)'%s).find(x) with your code would make it valid?
                                    $endgroup$
                                    – MilkyWay90
                                    7 hours ago












                                    $begingroup$
                                    @Neil Oh, wait, I see your golf
                                    $endgroup$
                                    – MilkyWay90
                                    6 hours ago




                                    $begingroup$
                                    @Neil Oh, wait, I see your golf
                                    $endgroup$
                                    – MilkyWay90
                                    6 hours ago












                                    $begingroup$
                                    79 bytes by shortening the inner string
                                    $endgroup$
                                    – dzaima
                                    6 hours ago




                                    $begingroup$
                                    79 bytes by shortening the inner string
                                    $endgroup$
                                    – dzaima
                                    6 hours ago












                                    $begingroup$
                                    You can switch to input() and save 4 bytes
                                    $endgroup$
                                    – Rod
                                    6 hours ago




                                    $begingroup$
                                    You can switch to input() and save 4 bytes
                                    $endgroup$
                                    – Rod
                                    6 hours ago











                                    1












                                    $begingroup$


                                    Charcoal, 37 bytes



                                    ≔´≔´´´η´F´Φ´θ´⁼´ι´κ´¬´№ηFηΦθ⁼ικΦθ¬№ηι


                                    Try it online! Explanation:



                                    ≔´≔´´´η´F´Φ´θ´⁼´ι´κ´¬´№η


                                    There are two ways of quoting characters in Charcoal; ´ quotes any single character while ”y... quotes any character except and also counts as a separate string. It turns out that the overhead in having to deal with means that it doesn't end up any golfier.



                                    FηΦθ⁼ικ


                                    Loop over the characters in turn, outputting any matching characters from the input. This sorts the input.



                                    Φθ¬№ηι


                                    Output any unmatched characters in the input.






                                    share|improve this answer









                                    $endgroup$

















                                      1












                                      $begingroup$


                                      Charcoal, 37 bytes



                                      ≔´≔´´´η´F´Φ´θ´⁼´ι´κ´¬´№ηFηΦθ⁼ικΦθ¬№ηι


                                      Try it online! Explanation:



                                      ≔´≔´´´η´F´Φ´θ´⁼´ι´κ´¬´№η


                                      There are two ways of quoting characters in Charcoal; ´ quotes any single character while ”y... quotes any character except and also counts as a separate string. It turns out that the overhead in having to deal with means that it doesn't end up any golfier.



                                      FηΦθ⁼ικ


                                      Loop over the characters in turn, outputting any matching characters from the input. This sorts the input.



                                      Φθ¬№ηι


                                      Output any unmatched characters in the input.






                                      share|improve this answer









                                      $endgroup$















                                        1












                                        1








                                        1





                                        $begingroup$


                                        Charcoal, 37 bytes



                                        ≔´≔´´´η´F´Φ´θ´⁼´ι´κ´¬´№ηFηΦθ⁼ικΦθ¬№ηι


                                        Try it online! Explanation:



                                        ≔´≔´´´η´F´Φ´θ´⁼´ι´κ´¬´№η


                                        There are two ways of quoting characters in Charcoal; ´ quotes any single character while ”y... quotes any character except and also counts as a separate string. It turns out that the overhead in having to deal with means that it doesn't end up any golfier.



                                        FηΦθ⁼ικ


                                        Loop over the characters in turn, outputting any matching characters from the input. This sorts the input.



                                        Φθ¬№ηι


                                        Output any unmatched characters in the input.






                                        share|improve this answer









                                        $endgroup$




                                        Charcoal, 37 bytes



                                        ≔´≔´´´η´F´Φ´θ´⁼´ι´κ´¬´№ηFηΦθ⁼ικΦθ¬№ηι


                                        Try it online! Explanation:



                                        ≔´≔´´´η´F´Φ´θ´⁼´ι´κ´¬´№η


                                        There are two ways of quoting characters in Charcoal; ´ quotes any single character while ”y... quotes any character except and also counts as a separate string. It turns out that the overhead in having to deal with means that it doesn't end up any golfier.



                                        FηΦθ⁼ικ


                                        Loop over the characters in turn, outputting any matching characters from the input. This sorts the input.



                                        Φθ¬№ηι


                                        Output any unmatched characters in the input.







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered 8 hours ago









                                        NeilNeil

                                        85.6k8 gold badges46 silver badges183 bronze badges




                                        85.6k8 gold badges46 silver badges183 bronze badges





















                                            1












                                            $begingroup$


                                            Ruby, 57 bytes





                                            ->ss.sort_byo


                                            Try it online!



                                            Fairly straightforward, assuming I haven't missed a golfing trick. Take in a list of characters and sort by their index in a string consisting of all the uniq characters in the code in order of their appearance. Often their first appearance is in that very string, but that doesn't change the order.






                                            share|improve this answer









                                            $endgroup$

















                                              1












                                              $begingroup$


                                              Ruby, 57 bytes





                                              ->ss.sort_byo


                                              Try it online!



                                              Fairly straightforward, assuming I haven't missed a golfing trick. Take in a list of characters and sort by their index in a string consisting of all the uniq characters in the code in order of their appearance. Often their first appearance is in that very string, but that doesn't change the order.






                                              share|improve this answer









                                              $endgroup$















                                                1












                                                1








                                                1





                                                $begingroup$


                                                Ruby, 57 bytes





                                                ->ss.sort_byo


                                                Try it online!



                                                Fairly straightforward, assuming I haven't missed a golfing trick. Take in a list of characters and sort by their index in a string consisting of all the uniq characters in the code in order of their appearance. Often their first appearance is in that very string, but that doesn't change the order.






                                                share|improve this answer









                                                $endgroup$




                                                Ruby, 57 bytes





                                                ->ss.sort_byo


                                                Try it online!



                                                Fairly straightforward, assuming I haven't missed a golfing trick. Take in a list of characters and sort by their index in a string consisting of all the uniq characters in the code in order of their appearance. Often their first appearance is in that very string, but that doesn't change the order.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered 7 hours ago









                                                histocrathistocrat

                                                19.5k4 gold badges32 silver badges74 bronze badges




                                                19.5k4 gold badges32 silver badges74 bronze badges




















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









                                                    draft saved

                                                    draft discarded


















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












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











                                                    tjjfvi 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%2f187415%2fa-quine-of-sorts%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

                                                    Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

                                                    The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

                                                    19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу