# Sort a list and write some English!

Your boss managed to read the secret hidden message. He didn't end up firing you, though, he just made you a secretary and forbade you from writing code.

But you're a programmer. You need to write code. You must code.

Therefore, your code needs to look as similar to English as possible, make sense, and look as little like code as possible. Your code should take a list of integers (either in a function, or STDIN), and return that list sorted (returning it, or STDOUT).

Any language can be used, but I'm looking for the most creative solution, (kudos if your code looks like a business letter).

This is a popularity contest!

• whitespace to the rescue? – kaine Sep 5 '14 at 19:26
• Or SPL. – Dennis Sep 5 '14 at 20:06
• I thought of SPL too, but Chef may be fun as well :P – Adriweb Sep 7 '14 at 0:12
• @Dennis That would be nearly impossible to figure out. – Isiah Meadows Sep 8 '14 at 21:43
• Funny.. there are no ruby submissions yet! :P – Gaurav Agarwal Sep 9 '14 at 8:22

# GolfScript

Dear Boss Man.

It came to my attention that my keyboard needs replacement; the keys required to write the
symbols ~ $ . and } are not functioning properly. It's very difficult to work like this! Please instruct the IT department to exchange the faulty keyboard as soon as possible. Sincerely, Dennis Try it online! ### How it works • Undefined tokens (e.g., most English words) are noops in GolfScript. • . ; duplicates the input string and discards the copy. • ~$ evaluates the input string and sorts the resulting array.

•  inspects the array (for pretty printing).

• . and duplicates the output string and discards the copy.

• } is a "super comment" since it is unmatched; everything following it is ignored.

• I'm guessing you wrote this on your other keyboard? – Geobits Sep 5 '14 at 20:23
• Perhaps he wrote it with the mouse keyboard hidden in the accessibility gaboodle? – Tally Sep 7 '14 at 19:34
• It's an inline comment... it's a block comment... it's a SUPER-COMMENT! – Doorknob Sep 7 '14 at 19:55
• @Geobits: Let's assume that "are not functioning properly" translates to "requires multiple attempts to eventually get the characters on the screen" – justhalf Sep 8 '14 at 1:37
• Or he used Character Map. – dan04 Sep 9 '14 at 2:42

# PHP

Defines a function called item that will sort an array that you pass it.

Dear Boss,
I have successfully discovered all brackets.
The ones marked with question marks are the ones which I am not sure about.
The ones marked with asterisks can be used both as an opening and closing delimiter.
(
)
{
}
[
]
>?
<?
/*
'*
"*

Thank you for reading my memo. In other news, the */ function item (#12 in the list of things that have an asterisk before them) was discovered recently, which I read on a local news site.
#12 is my favorite function item! Just thought you'd be interested. Sorry if this is too off-topic; here's some business stuff. Imagine that you had some (let's say you have a combination of $10 &$money) # of dollars (i.e. you have $10 +$money). Now, here's the important part. It's so important, I'll separate it from the rest of this message with the brackets I discovered:

{
#10 in my personal list of things to remember about money management is that you have to be careful. I still haven't been able to
sort #9 out yet (I bought the manual from someone else), but #9 also seems to be about being careful. You also have to guard the dollars
($money); #13 says that if you don't protect them by putting them in a bank or something, they might be stolen. } //-----------------------\\ // Signed, \\ // Your great employee \\ //-----------------------\\  It looks much better if you paste it into a text editor and resize the window so that you can see the entire thing on your screen at once. • "I have successfully discovered all brackets." Someone's going for employee of the month! – Martin Ender Sep 6 '14 at 0:19 • -1: You missed « and ». (In seriousness, +1.) – Kevin Sep 6 '14 at 21:19 • Wow man. :D Can't stop laughing – Ven Sep 8 '14 at 15:12 # Python 2 ''''''''''''''''''''''''''''''''''''''''''''' One of the phones in the office seems to be broken, so it needs to be fixed. '''''''''''''''''''' This memo was made while testing the functionality of its buttons since some of them didn't seem to work. '''''''' 1 (no alphabets) working with no problem '''''''' abc working with no problem ''''''''' def working (partially): please =( 'o" :\ at least I figured out that this was a problem! :') # list (phone number list) was missing as well, so I need to: #1 print (please, sorted (partially)) [1] # list, and [2] the memo #2 return #3 check (making-sure, ghi-jkl-etc. works) ''''''''''''''''''  • +1 love how you snuck in def to mean 'the letters on phone key 3'. – AJMansfield Sep 6 '14 at 19:25 ## Python 2 ''' 5th of September 2014 Dear Boss, I am writing this Mail because i want to discuss the recent incident. I am Thankful that you did not fire me, and gave me a secretary position instead. I dont have any experience in being a sec retary and I am not very. good at writing mail, so please excuse any spelling, grammar or formating errors in this mail. I will certainly try to improve and do my best in my new job and will''' 'from now on strictly ';exec'''ute your orders. = Firstly i want to sincerly apologize my dumb behaviour,it was idiotic ( and childish ). I really ;apologize to you. it wont .happen again, sir. If i could only reverse the timeline (to undo it all). Then i would; I really promise to never write code in any form Can i talk about that in a meeting with you? Maybe today at'''[4::15]#in the afternoon?  Finding the right words was a real pain. Input: [1,7,4,3] Output: [1,3,4,7] • This looks like those emails I get from Nigeria lol – Chris Cirefice Sep 8 '14 at 4:49 • @ChrisCirefice Well, these mails probably contain hidden code as well ;) The spacing and somewhat poor wording in my code is because every 15th character of the string after the exec forms a new string which is then executed. So the whole program is basically exec"y=input();y.sort();print y" – Markuz Sep 8 '14 at 12:45 • The ''' multiline string at the top is a dead giveaway, sadly, but +1 for "from now on strictly ';exec'''ute your orders." and good effort :p – Thomas Sep 12 '14 at 10:47 # C Input as space-separated list through STDIN, output as space-separated list through STDOUT. Dear Boss, I have made for you a decision about my employment a t your company. At about noon a letter explaining this shall be presented to you, as I am a lazy person. As you are a fool, I will say no more. And I look forward to never seeing you again. Insincerely, Steward Pitt  This should be compiled with: gcc bossletter.c -o bossletter -Dam='+++' -Dwill='---' -Dthis='{' -Dhave=';' -Ddecision=',' -Dquit='*' -Dfor='(' -Dmy=')' -Dbrain='}' -Dlie=']' -Dnoon='-quit' -DD='' -Dto='D' -Dyou='D' -Dfool='you' -Das='to' -Dday='D' -Dno='fool' -Dcake='Pitt' -Dlook='you' -DPitt='the' -Dthe='as' -DBoss='a[9999 lie' -DAs='a have' -Dlazy='my' -Dperson='lazy have company' -Dyour='this' -DInsincerely='a' -Dcompany='b' -Demployment='int quit' -DDear='struct this employment a have brain b have' -Dbe='scanf for' -Dis='I[' -Dnever='for presented " " decision' -Dthat='4 decision' -Dagain="my have b" -Dt='decision quit about have' -Dshall='while for' -Dpresented='"%" to "d"' -Dletter='have brain' -DAt='a have return quit' -Dmore='have b' -DAnd='a have shall' -Dare='qsort for' -Dforward='--my printf' -Dexplaining='main for my' -Dsay='1 decision that made my day' -DSteward='Boss have no brain' -Dseeing='the cake is a lie'  The code expands to: struct{ int *a; } b; a[9999], I; made(a, about) int *a, *about; { b.a; return *about - *a; } main(){ while(scanf("%d", I++ + a)); b.a; qsort(a, I-- - 1, 4, made); b.a; while(I--) printf("%d ", I[a]); b.a, a[9999]; }  • +1 for preprocessor abuse. Of course with that sort of thing you could arguably make it read like any piece of code you want. – fluffy Sep 6 '14 at 6:26 • You should have given meaning to keywords and variables and only used the preprocessor for special characters like braces. You didn't even make an effort. – bebe Sep 6 '14 at 15:24 • @bebe the more insolent the abuse, the better, IMHO :). – user16991 Sep 6 '14 at 19:52 • Next codegolf is to make this "source" compile to an implementation of Conway's Game of Life. -D golf! – slebetman Sep 8 '14 at 8:12 • @fluffy I love preprocessor abuse in obfuscated C. You can make almost anything in it valid C code with enough #define/-Ds. – Isiah Meadows Sep 8 '14 at 21:35 # NetLogo To Manager [IT] Let Sue sort it; then show Sue the end to the end  With indentation and capitalization changes, the code becomes clear(er). This defines a function called manager which takes a list as input and prints the list sorted. to manager [IT] let sue sort IT; then (semicolons introduce a comment) show sue the end to the end  • Definitely doesn't look like code. – Dennis Sep 9 '14 at 17:40 • I like this one a lot. – Nathan Merrill Sep 9 '14 at 18:11 # Python 2 & 3 ### Unfortunately, the employees of today just can't stop using hashtags all over the place... #WritingALetter #Business Dear Boss, #SecondLine I found this scrap of paper on the floor. It said " def sortl(l): # define a function return sorted(l) # returns the list, sorted " #ScrapOfPaper Just thought I should let you know. #Honesty From Laurence  [Worth a try, I guess?] • Great excuse for using comments, but unfortunately it contains actual code – user16402 Sep 6 '14 at 15:15 • Add print "hello" at the end – Anthony Pham Sep 16 '15 at 20:50 # Brainfuck Hey boss! This is the public key that you asked! >,[[-[>>+<<-]>+>]<[<<]>,]+>[>+<-]>[>[>+<<->-]<[<<.>>-]<<[>>+<<-]>>+>>] Pretty cool huh?  Copyright note: Note: I copy pasted it from here. As far as I know, that codes from site are has copyright cc by-sa 3.0 with attribution. If this method is illegal, let me know and I will try to delete this. • "Your code needs to look as little as code as possible." – Sean Latham Sep 6 '14 at 9:03 • It's a public key for encryption! Not code! Different! – Realdeo Sep 6 '14 at 9:03 • @Realdeo Don't forget the , on the second line will read more input after the program ran – proud haskeller Sep 6 '14 at 9:19 • Good catch! Editing it – Realdeo Sep 6 '14 at 9:21 • With brainfuck it should be much easier to just incorporate the code in plain text. > for example can be used for quotes (that's how it works in emails) and so on. – Ingo Bürk Sep 6 '14 at 10:42 ## JavaScript I'm not sure if I can outsmart him, but I can throw him off my trail! /*Hello Bossman I feel the need to alert you to a pressing matter. Nothing Dan from Marketing's head seems to be */function/*ing anymore. I have a lot of evidence, but not enough time to */sort/* through it. Should I just send it to you directly */(/*although I'm sure you have about a thou*/s/*and other things to do*/)/*? Nah, here's it in a summary: Dan seems to be overly facinated by the */{/* key on his keyboard, and presses it many times a minute. He */return/*ed his new Galaxy */s/*4, after trying to eat it, multiple times.*/. /*When Dan was tasked to */sort/* through the Haberson account, he attempted to stab his computer multiple times with a ruler */(/*he was eventually deterred by Jenny) Everyone backed off for a few days, but we all remembered. Later, we approached him about the incident, he claimed hostile working conditions and that he was unable to */function(/*. I think he m*/a/*y need to see a psychatrist. None of us feel safe to approach him on the topic again*/, b/*rining up conflict is something most of us like to avoid. (except Jenny*/) {/*Dan was then moved to a different spot in the building, in an attempt to give him a new environment. Despite the move he */return/*ed to his old desk every day, and wrote */a - b/* on the walls of the new spot. We all just sort of accepted that and the layout planner gave up after a week or two. One week we got a new employee in the office. When she went to say Hi to Dan, he screamed a - b over and over. Not sure what his fascination is there. b-c is a much superior algorithm. We're not really sure what caused this, but one day he switched from the { key to the */} /*key. Dan switched back the next day. There is an ongoing betting pool on what will happen next (general categories mostly*/) /*Currently the betting for him stabbing an actual person is at almost$20,000.

Please do something about Dan. If anything start a reality TV show from the security tapes.

On a completely unrelated note, I love this new */}/* key, it's really neat looking. Did my keyboard always have this?
Sincerely,
Zeke*/


function sort(s) { return s.sort(function(a,b) { return a-b }); }

• Comment abuse kinda renders this more obvious. – Isiah Meadows Sep 8 '14 at 21:39

# Dogescript

It's basically English, right?

shh oooot! my  keyybr oad is brokn. i ne ed neew 1.
such fixs much keys
keys dose sort
wow keys


translates to:

// oooot! my keyybr oad is brokn. i ne ed neew 1.
function fixs(keys) {
keys.sort();
return keys;
}

• I think your boss will fire you if you write like this... – TuxCrafting Jul 16 '16 at 10:36

# LiveScript

Try figuring this one out...Been sending him emails like this the whole time to allow for easy, more versatile copy-paste.

# Mr. Boss,
#
#     So, I'm done with this job. It is driving
#     me crazy. We aren't allowed to have *any*
fun =#(. I am planning on leaving this
#     company while you all poorly attempt to
#     sort all this out. Also, I would like to
#     mention that a specific single bit in the
sort # for your in-house algorithm gets
#     inverted. Happy hunting while I have fun
#     programming for another company far more
#     grateful than yours.
#
# Best regards,


1. Its standard library, Prelude.ls, has a native sort function.
2. Note the two missing hashes (comments). The first is far more obvious than the second.

It parses as this: "fun = sort", and compiles to this: "var fun; fun = sort;"

• By the way, the syntax highlighter is a fail. One of the comments isn't parsed correctly. – Isiah Meadows Sep 22 '14 at 22:01

# Detour (non-competing ;-; )

Dear Boss Man
In reality it was downloaded to the main drive, C://users/boss/recovery. Sorry for the confusion!


How it works:

The only important part is ://, and the line above it, z.. : means "put input here", the first / reflects it up to z, which is sort; it then goes up, wraps across the top, keeps going up from the bottom, then hits / from below, which bounces it left to the other /, which does the same thing, except this time wrapping around to ., or output.

Simplified version:

# Detour

Dear Boss Man
z.
://


Try it online!

# JavaScript (ES6)

      (a) => /*----------*\ <= (a)
|      Announcement      |
.   (a)    \*----------*/    (a)   .

sort (/* YOUR DOCUMENTS BEFORE 2/5 )*/

($,_) => /*--------*\ <= (_,$)
|         Warnings         |
//  (_-$) \*--------*/ ($-_)  //

/*( NO SMOKING IN OFFICE */)


Try it online!

Yes, I know the boss likes fancy decorations in his notices so I capitalized the texts and surrounded the texts with fancy symbols :)

PS. Why is the office still using TELNET?

Actually, removing comments and redundant blanks makes the stuff into (a)=>(a).sort(($,_)=>($-_)), and that's what the stuff intends ;P

# √ å ı ¥ ® Ï Ø ¿

I have only skimmed the other answer but I still think mine is by far the best (don't we all). The only problem is that this language is non-competing as language post-dates the challenge.

isolate quickly! Then read this short story: Funny Steve Jobs . A Short Story  by This Guy. Steve Jobs looked at the heavy stone in his hands and felt annoyed. He walked over to the window and reflected on his sunny surroundings. He had always loved nice Silicon Valley with its huge, hurt houses. It was a place that encouraged his tendency to feel annoyed. Then he saw something in the distance, or rather someone. It was the figure of Bill Gates. Bill was a happy monster with young heads and old feet. Steve gulped. He glanced at his own reflection. He was a funny, irritating, beer drinker with skinny heads and ginger feet. His friends saw him as an abundant, average angel. Once, he had even made a cup of tea for an unusual old lady. But not even a funny person who had once made a cup of tea for an unusual old lady, was prepared for what Bill had in store today. The sun shone like coding dogs, making Steve violent. As Steve stepped outside and Bill came closer, he could see the anxious smile on his face. Bill glared with all the wrath of 9230 stupid healthy humans. He said, in hushed tones, "I hate you and I want money." Steve looked back, even more violent and still fingering the heavy stone. "Bill, you stole my idea," he replied. They looked at each other with angry feelings, like two creepy, curried cats challenging at a very sad party, which had jazz music playing in the background and two annoying uncles doing to the beat. Steve regarded Bill's young heads and old feet. "I feel the same way!" revealed Steve with a delighted grin. Bill looked sad, his emotions blushing like a charming, cheerful computer. Then Bill came inside for a nice drink of beer. THE END


# Groovy

'Dear Bossman,
I finally found the formula to calculate the salary for the new employees.
In the salary software just enter the following:'
print "${(args.toList()*.toInteger()).sort()}"' Sincerely, Employee'  • You're not supposed to be writing code. That's code. – Zach Mertes Sep 6 '14 at 6:56 • I quite like this one. It's just hiding the code in plain sight. – user16991 Sep 6 '14 at 19:55 • LOL you should put "I've found the Excel formula" then. Though I'm quite familiar with Excel, the reference never crossed my mind. – user16991 Sep 7 '14 at 9:30 • @kuroineko Excel formulas dont have such a programmy syntax, do they? – Little Child Sep 7 '14 at 11:50 • 8 upvotes and 9 downvotes? Wow; this is controversial. – Ypnypn Sep 9 '14 at 0:14 # Zsh I don't know whether the code or the creative writing was harder. : RE: The state of the evaluation process; eval #problems' : While I appreciate your enthusiasm, going to print  : this for the world to see isn't helpful in the long run. : Please, don't make any more enemies than you already have. : : > People seem to just want that '$': It's a big problem
: > which needs to be resolved. People need to buy into the
: > company's team-based philosophy '{': ... ''}''
:
: While I do not deny that people "just want that '$'", : I absolutely disagree that it's a _bad_ thing. Employees : should not be guilty for wanting to leave for greener : pastures, so you should try and provide _some_ incentive : to stay. : : > And yet everyone want's to just check "(y)" or '(n)' : > without giving _any_ further feedback... You're too LAZY! : : I want to stop you here. Accusations like this against my : team are _not_ to be tolerated. We do a _lot_ behind the : scenes which you _clearly_ aren't aware of. Please refrain : from '@-ing'' any of my team, and think with a bit more : empathy next time, thank you. -- Gamma :-}'  Try it online! • Note: This will create files named "People" and "without" in the directory it is run from. • From the first line, you can see the eval, followed by backticks. • # comments continue to end-of-line, stopping quotes or backticks from being resolved, so we use : no-ops to indent. • The standard pattern we make use of throughout this is  : lots of filler text.... : more filler text, then an important 'X' : back to the garbage  • At the end is one exception: Everything from @-ing to the last } is not no-op'd. • When the substitution has finished, it reads: eval print$'${(n)@-ing any of my team, and think with a bit more\n: empathy next time, thank you.\n\n-- Gamma :-}' The garbage after the @ does nothing, so this is equivalent to print${(n)@}, which is simply a numeric sort of the parameters.

# Jelly, 91 bytes

Gee Boss,
Go to Starbuck. Whoops, forgot the (sorry for the dot, my keyboard's messed up)
Ṣ


Try it online!

# 05AB1E

Dear Boss‚

I hope I{quality for this new function. I once again want to sincerely appologize for my earlier secret message.
Thank you for giving me the opportunity to work at this appartment instead.
I must admit it's hard to resist the urge to write code, but I'll do my best.

Thank you.

Kind regards from your new secretary,
Kevin Cruijssen


Try it online. (TIO uses the legacy version which is a bit faster. Works the same as the new 05AB1E version, though.)

Explanation:

05AB1E code ignores newlines and spaces outside of strings or compressed string/numbers (except when using the (if-)else-statement I just found out in an earlier attempt of making this program.. >.>), so let's do the same in this explanation.

DearBoss‚Ihope # These are all no-ops; they do execute, but won't affect the output:
D              #  Duplicates the (implicit) input-list
e             #  Calculates the number of permutations of each item in the list
#  (NOTE: this might time-out depending on the values in the input-list)
a            #  Check if these numbers are letters (becomes a list of 0s / falsey values)
r           #  Reverse the items on the stack
B          #  Base conversion
o         #  Raise 2 to the power of each number
s        #  Swap the top two items on the stack
s       #  Swap the top two items on the stack
‚      #  Pair the top two items
#  (NOTE: This is not a regular comma (,), since that would print the top of
#   the stack to STDOUT, which we of course don't want here.)
I     #  Push the input-list again
h    #  Convert each value to hexadecimal
o   #  Raise 2 to the power of each integer value
p  #  Check for each if it's a prime
e #  Calculate the number of permutations of each item again

I{q            # Then the actual program comes:
I              #  Push the input-list
{             #  Sort it
q            #  Stop the program
#   This makes everything that comes after it no-ops
#   And will output the top of the stack implicitly as result


Try it online with added debugger-mode to see all this in action.

# JavaScript (Node.js)

Attachment => (

Date: 2019/5/30

Dear my Majestic Boss,

I'm writing to confirm itinerary for the next trip to Japan will be as follows:

? (Tennoji, Osaka) => ("Shinsaibashi Tower", Osaka)

|| // Day 1

Tennoji [Osaka, "sort"]
(Hotel = (JPY$14112, Taxed) => So I will stay here for one night, and I will be charged this price: ? JPY$14112 + (0 - Taxed)
:This is the total price and what I will claim afterwards.

):0) (Attachment)

|| // Day 2

"Shinsaibashi Tower" [Conference, NOT FOR SHOPPING]

I will be coming back on Day 2, so the trip will not cost too much hopefully.

Best regards,
The-former-programmer


Try it online!

Okay this is an itinerary apparently. Another answer in different direction after one year.

The really important part is Attachment => (Tennoji => Tennoji["sort"]((JPY$14112, Taxed) => JPY$14112 - Taxed))(Attachment)

C#

// Dear Boss Man,

/*i have a */public/*shed a*/ List /*of*/ <string>/*s
to*/ Sort /*for you on our internal website
please take a look at the */(List /*of*/ <string>/*s and*/ check){
/*them for company restrictions. please also */check /*the */.Sort();/*ing of the     list*/
/*furthermore could you please */return /*an email to me in which you state your */check/*ing state*/;}


• Obvious comments :) The first line reads public List <String>`, without a lot of hassle :) – Martijn Sep 9 '14 at 7:24