6
\$\begingroup\$

Challenge

Create a quine, that instead of outputting it's source, output's it's source QWERTY-sorted.

What is QWERTY sorting?

QWERTY sorting is sorting code by the QWERTY keyboard. Anything higher or more left is greater (q > Q, \ > /) with presedence on higher. To check, find the locations of the two characters to compare. Find which character occurs first in the following table (left to right, up to down). The first character is the smaller one.

qwertyuiop[]\
asdfghjkl;'
zxcvbnm,./
QWERTYUIOP{}|
ASDFGHJKL:"
ZXCVBNM<>?
1234567890-=!@#$%^&*()_+~` 

(there is a trailing space and linefeed)

Examples:

Code Golf -> eoodflGC 
Programming -> rroiagnmmP

(note trailing space on Code Golf)

Specifications

  • Only characters in the above list are allowed in the source code!
  • This is .
  • Only Proper Quines are allowed (adapted to QWERTY sort).
  • Output must be in increasing QWERTY order.
\$\endgroup\$
15
  • 2
    \$\begingroup\$ You should make explicit that proper quines are required. \$\endgroup\$ – Dennis Apr 27 '16 at 15:31
  • \$\begingroup\$ :D Jelly can't win this, it is mostly non-ascii!!! \$\endgroup\$ – Rɪᴋᴇʀ Apr 27 '16 at 15:35
  • 4
    \$\begingroup\$ @ΈρικΚωνσταντόπουλος What part don't you understand? It reads pretty clear to me. \$\endgroup\$ – Morgan Thrapp Apr 27 '16 at 15:55
  • 4
    \$\begingroup\$ Why is f > G > l? The keyboard diagram implies that all lowercase comes before all uppercase, but these examples imply that the upper and lower cases of a letter are right next to each other, i.e. qQwWeE... is sorted. \$\endgroup\$ – algorithmshark Apr 27 '16 at 16:15
  • 2
    \$\begingroup\$ "Anything higher or more left is greater" - This is somewhat ambiguous, what about w and a? w is above a but also to the right of it? I think you need to say which takes precedence. \$\endgroup\$ – FryAmTheEggman Apr 27 '16 at 16:46
3
\$\begingroup\$

CJam, 25 23 bytes

{`"_~"+{"#$_+~`"`#}$}_~

Thanks to @MartinBüttner for golfing off 2 bytes!

Try it online!

How it works

{                   }_~  Define, copy and execute a code block.

   `                       Create a string representation of the code block.
  "_~"+                    Append that string.
       {          }$       Sort the characters by the following:
        "#$_+~`"`#           Compute the 0-based index of the character in that
                             string. Returns -1 if not found.
                           Since `$' is stable, all characters with tied index -1
                           will appear at the beginning, in their original order.
                           This places {{}} at the beginning, followed by
                           """"##$$___++~~~```.
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.