g | x | w | all
Bytes Lang Time Link
049AWK250829T161749Zxrs
001Thunno 2230721T062414ZThe Thon
002Thunno230305T090038ZThe Thon
00105AB1E200806T101931ZKevin Cr
040Brainfuck151125T153622ZDennis
101C++151126T155442ZSahil Ar
140Brainfuck150825T205707ZCoffeeCl
002Ostrich150820T201230ZAlex A.
023Ruby150821T200219Zclapp
034JavaScript150819T141310ZNinjaBea
061C with x86150819T084629Zlynn
179pb INVALID150821T195254Zundergro
035Clojure150821T175210ZKChaloux
135C++150821T161155Zuser4322
047PHP150821T012949ZGeorgeQ
091Lua150821T005148ZTrebuche
049Bash + coreutils150820T191520Zpawel.bo
005Matlab150819T135751ZLuis Men
020jq150820T081905Zgilad ho
027PowerShell150820T085058ZNacht
021Julia150819T150309ZGlen O
073Nim150819T120324ZSp3000
040Processing150819T165707ZKevin Wo
079Lua150819T161613ZHenrik I
119Java 8150819T135947ZpretzelK
037Powershell150819T130902ZStephan
032JavaScript ES6150819T145510Zrink.att
005Stuck150819T141208ZKade
430GOTO++150819T080519ZFatalize
110C#150819T074003Zuser3094
054JavaScript150819T115327ZMarcel
004Stuck150819T101353Zlynn
001gs2150819T101904Zlynn
021Scala150819T103938Zgilad ho
007APL150819T103600Zlynn
046Idris150819T102605Zlynn
032Python 2150819T092757ZBlue
017Ruby150819T082500Zlynn
023Coreutils150819T074056ZThor
018Perl150819T074313Zsamgak
002Pyth150819T083329ZKamehame
035Haskell150819T081246Zlynn
003J150819T083421ZFatalize
034SWIProlog150819T081830ZFatalize
002CJam150819T081410Zlynn
001GolfScript150819T072955Zjimmy230
031Python 3150819T074938ZKamehame

AWK, 49 bytes

{l=split($0,a,X);for(asort(a);j++<l;)printf a[j]}

Attempt This Online!

Here's a version without a sort function that I thought was fun:

@load"ordchr"
{l=split($0,a,OFS=$0=X);for(;i++<l;)$t=a[i]$(t=ord(a[i]))}1

Thunno 2, 1 byte

Try it online!

Built-in for "sort".

Thunno, 2 bytes

z:

Attempt This Online!

Output as a list of characters. Add the J flag if you want a string.

05AB1E, 1 byte

{

Try it online or verify a few more test cases.

Also works in 05AB1E (legacy) or 2sable, which are older versions of 05AB1E.

Explanation:

{  # Sort the characters of the (implicit) input-string
   # (after which the result is output implicitly)

Brainfuck, 40 bytes

,[>>+>>,]<<[[<<]>>[-[<]>>[.<<->]>+>>]<<]

This uses the counting sort algorithm, which makes this an O(n) solution.

The code requires a left-infinite or wrapping tape of 8 bit cells. Try it online!

How it works

,          Read a char from STDIN.
[          While the byte under the pointer (last read char) is non-zero:
  >>+        Move the pointer two steps to the right and increment.
  >>,        Move the pointer two steps to the right and read a char.
]
<<         Move the pointer two steps to the left.

           If the input was "sort", the tape now contains the following:
           0 0 115 0 1 0 111 0 1 0 114 0 1 0 116 0 1 0 0
                                                   ^

[          While the byte under the pointer is non-zero:
  [<<]       Advance two steps to the left until a null byte is encountered.
  >>         Advance two steps to the right.

             This will place the pointer on the first input character.

  [          While the byte under the pointer is non-zero:
    -          Decrement.
    [<]        Move the pointer to the left until a null byte is encountered.
    >>         Move the pointer two steps to the right.

               If the decremented character is non-zero, [<] will move to the
               null byte before it, so >> brings the pointer to the null byte
               after it. If the decremented character is zero, [<] is a no-op, so
               >> advances two steps to the right, to a non-zero byte.

    [          While the byte under the pointer is non-zero:
      .          Print the char under the pointer.
      <<-        Move the pointer two steps to the left and decrement.
      >          Move the pointer to the right.
    ]

               If the decremented character gave zero, this will print the value
               of the accumulator after it, and decrement the character once more
               to make it non-zero, then place the pointer to the right of the
               character, thus exiting the loop.

    >+         Move the pointer to the right and increment.

               This increments the accumulator each time an input character is
               decremented.

    >>         Move the pointer two steps to the right.

               This moves the pointer to the next character.
  ]
  <<         Move the pointer two steps to the left.

             This moves the pointer to the accumulator of the last character.
]

             After 255, th accumulator wraps around to 0, and the loop ends.

C++, 101 Bytes

#include<bits/stdc++.h>
using namespace std;main(){string s;cin>>s;sort(s.begin(),s.end());cout<<s;}

Brainfuck, 140 bytes

Probably not the winning post, but still it was fun :)

----------[++++++++++>>,----------]<<[[<<]>>>>[[<<[[-<+>]>>>+<<<]<[->+<]>>>>[-<-<+<->>>>>+<<]>>-[+<<<[-<<+>>]>>>]<<<]<[-<+>>+<]>>>]<<.[-]<<]

Explanation:

Program loads whole line and performs bubble sort. After each sort iteration prints and removes last character. It's always the smallest one, because bubble sort guarantees, that after every iteration the lowest value is in the end. Stops after removal of all characters.

#read line
----------[++++++++++>>,----------]<<

#MEMORY MODEL OF WHOLE PROGRAM:
# 0|0|?|0|?|0|?|0|?|0|0
#     C   C   C   C
# C-character from input

#iterate if there are characters
[
    #go to first letter
    [<<]>>

    #MEMORY MODEL OF TWO SORTED CHARACTERS:
    # 0|?|0|?|0|?|0|?
    # S L M R F   G
    # S - swap of left during left 0 check
    # L - left character
    # M - middle, difference between left and right
    # R - right character
    # F - flag, set if left was not 0
    # G - next flag, set if left was 0

    #sort two characters if there are at least two
    >>[        
        #while right is not 0
        [
            #if left is not 0
            <<[[-<+>]
                #set flag
                >>>+<<<
            #clean up after left's 0 check
            ]<[->+<]>

            #if flag is set, so left is not 0
            >>>[-
                #move 1 from left and right to the middle
                <-<+<->>>
                #set next flag
                >>+<<
            ]

            #if next flag is not set, so left was 0 
            >>-[+
                #transfer right to left
                <<<[-<<+>>]>>>
            ]

        #while right is not 0
        <<<]

        #distribute middle to left and right
        <[-<+>>+<]>

    #end if it was the last character
    >>]
    #write and clear last character
    <<.[-]
#end if no more characters
<<]

Ostrich, 2 bytes

G$

In Ostrich G reads a line of input from STDIN and $ sorts it.

Ruby, 23 bytes

puts gets.chars.sort*''

Splits string by empty regexp, sorts array, joins array. Thanks to @MartinBüttner for 6 bytes :D

JavaScript, 34 bytes

alert([...prompt()].sort().join``)

The reason this is so long is that JavaScript can only sort arrays, so the string must be split into an array, sorted, and then joined back into a string. This is ECMAScript 6; the equivalent in ES5 is:

alert(prompt().split('').sort().join(''))

C (with x86), 61 bytes

s[];main(){qsort(s,read(0,s,99),1,"YXZQQQ\x8a\x00*\x02\x0f\xbe\xc0\xc3");puts(s);}

That string contains raw bytes, not actual \x.. codes, and it's a raw machine code callback passed to qsort. Works on x86 only:

59         pop   ecx
58         pop   eax
5a         pop   edx
51         push  ecx
51         push  ecx
51         push  ecx
8a 00      mov   al,  BYTE PTR [eax]
2a 02      sub   al,  BYTE PTR [edx]
0f be c0   movsx eax, al
c3         ret

Which is essentially:

int func(char *a, char *b) { return *a - *b; }

See p6-7 of this pamphlet in Japanese by shinh.

pb (INVALID), 179 bytes

^w[B!0]{w[B!0]{>}<t[B]^b[T]vb[0]<[X]<vb[B+1]^>}^w[B!0]{w[B!0]{>}<t[B]b[0]<[X]v[T+2]w[B!0]{>}b[T]<[X]^[Y+2]}vv<w[B!0]{>vw[B=0]{v}w[B!0]{>}<t[B]b[0]^[Y]<[X]w[B!0]{>}b[T]<[X]<b[B-1]}

Answers on this site are only considered valid if the language they're written in was available (e.g. there was an interpreter) at the time the question was posted. I didn't finish pb's interpreter until the day after, so this answer is just for fun and is ineligible to win (not that it was going to). That's also why I formatted the header of this answer incorrectly; I don't want to show up in the leaderboard snippet :)

Here's the code with comments, though I'm not sure they'll be helpful to anyone trying to decipher this. I just wrote them to keep my thoughts straight while writing the program, so they're kind of redundant and all over the place.

^w[B!0]{                     # while there's something at (0, -1)
    w[B!0]{>}<t[B]^b[T]vb[0] # move last byte of input up by 1
    <[X]<v                   # go to (-1, 0)
    b[B+1]                   # increase by 1
    ^>}                      # restart loop
^w[B!0]{                     # while there's something at (0, -2)
    w[B!0]{>}<t[B]b[0]       # save last byte of input and erase it
    <[X]                     # go to (0, -2)
    v[T+2]                   # go down T+2
    w[B!0]{>}b[T]            # go right until there's nothing there. write T
    <[X]^[Y+2]}              # restart loop
vv<w[B!0]{                   # while there's something at (-1, 0)
    >vw[B=0]{v}              # go down the X=0 column until you find something
    w[B!0]{>}<t[B]b[0]       # save the rightmost thing and erase it
    ^[Y]<[X]w[B!0]{>}b[T]    # add the thing you got to Y=0, to be outputted
    <[X]<b[B-1]}             # decrease (-1, 0) by 1 and repeat loop

Clojure, 35 Bytes

(print(apply str(sort(read-line))))

This will prompt the user for input, sort the characters, rejoin them back into a string and print it.

However, we can make it 3 bytes smaller if we allow the result to include quotations:

(pr(apply str(sort(read-line))))

pr is a debugging tool that prints the object it's given rather than its contents, so instead of showing hist in the console, it will show "hist".

C++, 135 bytes

#include <iostream>
#include <string>
#include <algorithm>
main(){std::string s;std::cin>>s;std::sort(s.begin(),s.end());std::cout<<s;}

http://coliru.stacked-crooked.com/a/7c9d5c37c2783a23

I payed for what I used :P

PHP, 47 bytes

$a=str_split($argv[1]);asort($a);echo join($a);

Lua, 91 bytes

a=table t={}for c in arg[1]:gmatch(".") do t[#t+1]=c end a.sort(t)print(a.concat(t))

Lua has no string sort function or split/explode function, so it was a struggle

Bash + coreutils (49 bytes)

Bash was not yet submitted, here is a script (needs to be in a file, as it recurses):

[ $1 ]&&(echo ${1::1};$0 ${1:1})|sort|tr -d '\n'

I just recursively output head, call the script with the tail of the word in order to split the input word ($1) to single chars and then use sort util.

However I believe a shorter solution using bash+coreutils exists... Any ideas?

Matlab, 13 5 bytes

The code simply defines a function handle to the sort function:

@sort

To call it, use ans('this'), where 'this' represents the input string (thanks to Alex A. and Stewie Griffin):

>> @sort
ans = 
    @sort
>> ans('this')
ans =
hist

jq, 20 bytes

explode|sort|implode

try it here

PowerShell, 27 bytes

%{([char[]]$_|sort)-join''}

Julia, 21 bytes

s->join(sort([s...]))

And for fun, here's how you might do it without using an inbuilt sorting function, for 53 bytes:

f=s->s>""?(k=indmax(s);f(s[k+1:end]s[1:k-1])s[k:k]):s

Nim, 102 101 79 73 bytes

let s=stdin.readAll
for i in 1..'~':
 for j in s:(if i==j:stdout.write j)

Still learning Nim and working out golf tricks. Apparently it's better not to use the builtin sort, which would require a lot of imports (thanks @Mauris)

Processing, 40 bytes

print(join(sort(args[0].split("")),""));

Lua, 79 bytes

t=table for c in({...})[1]:gmatch"."do t:insert(c)end t:sort()print(t:concat())

Obviously, I could save a few bytes if the string was already in a variable (say, s):

t=table for c in s:gmatch"."do t:insert(c)end t:sort()print(t:concat())

Java 8, 119 bytes

This is basically only competitive with the C# answer, because, well, Java.

(At least this beats GOTO++. Not really an accomplishment...)

class C{public static void main(String[]s){s=s[0].split("");java.util.Arrays.sort(s);System.out.print("".join("",s));}}

Thanks to ProgramFOX for saving 1 byte, rink.attendant for saving 2 bytes.

Powershell, 44 37 Bytes

-join((Read-Host).ToCharArray()|sort)

JavaScript (ES6), 32 bytes

Demo only works in Firefox and Edge at time of writing, as Chrome/Opera does not support ES6 by default:

Edit: I didn't look at the answers prior to posting but now I realize it's pretty much the exact same as the one by NinjaBearMonkey.

f=x=>alert([...x].sort().join``)
<form action=# onsubmit='f(document.getElementById("I").value);return false;'>
  <input type=text pattern=\w+ id=I>
  <button type=submit>Sort letters</button>
</form>

Stuck, 5 Bytes

I finally get to use my language, Stuck! :D

s$""j

This takes an input via stdin, sorts, joins, and implicitly prints. This did give me some ideas for changes though.

Edit: Oh wow, someone already posted and beat me in my own language!

GOTO++, 432 430 bytes

GOTO++ project site.

niveaugourou 0
s=ENTRETONTEXTE()
§2 a=LeCaracNumero()&s *(1)
n=*(1)
costaud i=*(2)/&i infeg NombreDeLettres(&s)/i=+*(1)
b=LeCaracNumero()&s &i
GOTONULPOURLESNULS %1 }&b inf &a{
a=&b
n=&i
§1 faiblard
GOTOPRINTDUTEXTE()&a
t=PrendsUnMorceau()&s *(0) &n
u=PrendsUnMorceau()&s }&n+*(1){ *(0)
e=BOITEAPINGOUINS()&t &u
s=Marijuana()&e «»
GOTONONNULPOURLESNULS %3 }NombreDeLettres(&s) eg *(1){
GOTOPASMALIN %2
§3 GOTOPRINTDUTEXTE()&s

Not sure why I inflicted this to myself, but I did

C#, 114 110 characters

Takes input from a command line argument. Not a very short program, but well... it's C#. :P

namespace System.Linq{class P{static void Main(string[]a){Console.Write(string.Concat(a[0].OrderBy(x=>x)));}}}

Thanks to Abbas for saving 4 bytes!

JavaScript, 54 bytes

call js file with node

console.log(process.argv[2].split('').sort().join(''))

Stuck, 4 bytes

sc$d

This language was documented on the wiki just yesterday! Mmm, fresh esolangs.

gs2, 1 byte

/

Same as the GolfScript answer, but gs2 uses a different operator for sorting.

Scala, 21 bytes

print(args(0).sorted)

run from command line example:

$ scala -e "print(args(0).sorted)" this
hist

APL, 7 characters

Doesn't work on ngn-apl for me, but should work in theory:

X[⍋X←⍞]

reads a line from standard input, which is assigned to X. ⍋X is the indices of X which yield an ascending order, and X[...] actually sorts X by these indices.

Idris, 46 bytes

main:IO();main=putStr$pack$sort$unpack!getLine

Python 2, 33 32 bytes

print`sorted(raw_input())`[2::5]

Heavily inspired by @Kamehameha's answer. Converted to python 2. Can't golf much more.

Ruby, 17 bytes

$><<$<.chars.sort

Coreutils, 24 23

fold -w1|sort|tr -d \\n

Perl, 18 bytes

print sort<>=~/./g

Thanks to Dom Hastings for helping me save 3 bytes.

Pyth, 2 bytes

Sw

DEMO HERE.

Details-

S - for sorting
w - Python 3's input()

Haskell, 35 bytes

import Data.List;main=interact sort

J, 3 bytes

/:~

For example: /:~'this'

SWI-Prolog, 34 bytes

a(X):-msort(X,Y),writef("%s",[Y]).

Called as such:a(`this`).

CJam, 2 bytes

l$

Reads a line of input (l) and sorts it ($).

GolfScript, 1 byte

$

Yes, only 1 byte.

Try it here.

Python 3, 31 Bytes

print("".join(sorted(input())))