text:
Converting a string to lower-case (without built-in to-lower functions!)
The goal of this code-golf is to create a code that lets the user input an ASCII string (contains only printable ASCII characters), and your program outputs the lower-case variant of this string.
Important: you are NOT allowed to use a built-in function that converts the string (or just one character) to lowercase (such as ToLower() in .NET, strtolower() in PHP
, ...)! You're allowed to use all other built-in functions, however.
Another important note: The input string doesn't contain only uppercase characters. The input string is a mix of uppercase characters, lowercase characters, numbers and other ASCII printable characters.
Good luck!

unfortunately, I'll have to opt-out. I'm not a beginner.

@Jan: Well, with beginner I actually meant that the skill level of this would be 'beginner', not that only beginners would be allowed to enter. I removed the word 'beginner' and surely, you're allowed to enter.

Are regular expressions allowed? Only GolfScript could beat s/./\L\0/g.

@manatwork: surely \L is built in?

@manatwork: Yes, a regex is allowed.

@marinus is builtin, but not a function. (This would be a function in the regular expression: s/./lc$&/ge, so this one clearly not allowed.)

@ProgramFOX, can we assume the input will contain only uppercase letters and no other characters?

@manatwork: No, the input will contain uppercase letters, lowercase letters, numbers, and some other ASCII characters.

May the input string contain control characters such as tab, line break, carriage return, or is only the range of ASCII printable characters valid input? What about null bytes, do they have to be replicated in the output?

@FireFly: Only printable characters. I didn't mention that in the question, so it's updated now.

Shell - 10
Translation of @Gowtham's Perl solution using /bin/tr.
tr A-Z a-z

Sample run:
% tr A-Z a-z <<<'Hello WORLD! @'
hello world! @

What makes this the accepted answer, out of curiosity? Gowtham had a 10-character solution first…

Based on the discussion on meta it seems the reasoning is that Gowtham's solution is 11 chars (because the -p flag counts as one).  I agree though, his seems like it deserves more to be accepted..

Ah, thanks – that makes sense. I’ll keep it in mind!

Python 2.7 - 30 (with terrible and unapologetic rule abuse)
raw_input().upper().swapcase()

As an anonymous edit pointed out, you can do it in 27 26 in Python 3:
input().upper().swapcase()

I'm flagrantly abusing the rules here, but...

Important: you are NOT allowed to use a built-in function that converts the string (or just one character) to lowercase (such as ToLower() in .NET, strtolower() in PHP
  , ...)! You're allowed to use all other built-in functions, however.

This takes the strings and coverts it to upper case. Then in a very unrelated method call, it reverses the case of the string - so that any lower case letters become upper case letters... and swaps any upper case letters to lower case letters.

The Python 3 solution is 26 characters.

@Timtech I can't count.

It's not just unrelated. It's very unrelated.

This will have strange results when encountering text that contains the characters ß.

Perl - 11 10 characters.
y/A-Z/a-z/

y/// is same as tr///!
In action:
% perl -pe 'y/A-Z/a-z/' <<< 'Hello @ WORLD !'
hello @ world !

+1, for the only real-life language that beat out all the less(?) real ones.

Actually that is 11 characters. The -p option is counted as 1.

@manatwork Or it should be counted as 2 : - and p :)

1 if you assume -e (perl -e -> perl -pe), 3 if you assume a script (perl -> perl -p).

This could be 9 using y;A-Z;a-z instead!

Befunge-98 - 26 22 21 19
~:''-d2*/1-!' *+,#@

Relies on the fact that (c-39)/26 is 1 only for character codes of uppercase ASCII characters (assuming integer division).  For each character c, print out c + (((c-39)/26)==1)*' '.
Sample session:
% cfunge lower.b98
hello WORLD!
hello world!
This is a TEST!!11 az AZ @[`{
this is a test!!11 az az @[`{

Python 3, 48
input().translate({c:c|32for c in range(65,91)})

Can you explain how this works?  I'm really interested in getting better at Python.  I don't get how the map(ord,input()) bit works.

@JeffGohlke: map applies a function (in this case, ord) to an interable and returns an iterable. It’s like a shorter form of (ord(x) for x in input()).

Got it.  Thanks for the explanation!

Your answer follows the spirit of the question, but mine follows the letter of the question...

Very nice.  Beat my unposted 62 length solution for c in input():print([c,(chr(ord(c)+32))]['@'<c<'['],end='').  I tried some with the map(ord,input()) trick, but missed the multiplying the truth value by 32 and adding it to the character code trick.  Very nice.

Ruby, 18 characters
Nothing really interesting.
gets.tr'A-Z','a-z'

(run in IRB)
Just for fun: a confusing version:
$,=$* *' ';$;=$,.tr'A-Z','a-z';$><<$;

Run like this:
c:\a\ruby>lowercase.rb Llamas are AMAZING!

Output
llamas are amazing!

J - 30
'@Z'(]+32*1=I.)&.(a.&i.)1!:1]1

J is read right-to-left, so to break this down:

Prompt user for input: 1!:1]1
Perform algorithm in code-point-space:  &.(a.&i.)
Identify character range for each letter; the characters between codepoints "@" and "Z" are considered uppercase: 1=I..
For each uppercase codepoint, add 32: ]+32* ...
Note that step (2) creates an implicit step (5): we started out by projecting from character to integer domain, so now that we're finished, we map those integers back onto characters.

Obviously this particular implementation only considers ASCII; but the approach could be extended to at least the basic multilingual plane in Unicode.

Nice! Unfortunately, it seems your solution is going the WRONG WAY. ;-)  Should be an easy fix though.  (Edit: '@Z'(]+32*1=I.)&.(a.&i.)1!:1]1 should do it)

Nice catch, thanks.  I'm also impressed you were able to fix the code yourself: J isn't the most immediately-accessible language out there :)

Ah, I've played around some with J myself.. I managed to come up with u:(a.i.x)+32*1='@Z'I.x=.1!:1]1, which matches your length but is much less interesting (as it doesn't make use of 'under'). Speaking of which, I didn't know about dyadic I., so thanks for using that. :-)

Cool. But your Befunge solution still has J beat by 4 characters. Obviously I can't let that stand :) I'm trying to see if trim the J solution down by following your lead in relying solely on '@', rather than both '@' and 'Z'.

(32(23)b.])&.(3&u:), should be 5 bytes shorter.

23 b.&32&.(3&u:)

C 64 63 59 55 chars
main(c){while(c=getchar(),~c)putchar(c-65u<27?c+32:c);}

I count only 63 characters there.

You can lose 9 characters: drop int  and ,c>=0. They're not necessary here.

we need c>=0 as getchar(EOF) will be < 0. Thanks for other suggestion.

~(c=getchar()) 2. c-64u<27

Thats great, have incorporated your suggestions. Thanks

You can save one more by c=~getchar(). It will require some work on your putchar though.

Insignificantly small bug: seems there should be 65 instead of 64. http://pastebin.com/Zc9zMx2W

53 bytes, also fixed a bug with [ being translated to {

Golfscript - 17
Program:
{..64>\91<*32*+}%

Explanation:

{}% maps the code inside to every character in string.
.. copies the top of the stack (the character) twice.
64> 1 if character code is greater than 64, else 0.
\ swaps the two items on the stack (gets the second copy of the letter, and stores the result of 64> in position two).
91< checks to see if character code is less than 91. Similar to step 3.
* multiplies the results from steps 3 and 5 together. Only equal to 1, if both steps were true.
32* multiplies the result of step 6 with 32. Will be 32 if step 6 was 1, else 0.
+ add the result (either 32 or 0) onto the character code.

Example output:
echo HelLO @ WorLD | ruby golfscript.rb upper_to_lower.gs
hello @ world

05AB1E, 3 bytes
u.š

Port of @user8777 Python 3 answer.
Try it online.
Explanation:
u    # Convert the (implicit) input to uppercase
 .š  # Switch the case (upper to lower and vice-versa)
     # (and output the result implicitly)

But without any case-altering builtins:
05AB1E, 12 11 6 bytes
žn2ä`‡

-1 byte thanks to @Emigna.
-5 bytes thanks to @TheThonnu
Try it online.
Explanation:
žn      # Push builtin string "ABC...XYZabc...xyz"
  2ä    # Split it into two equal-sized parts: ["ABC...XYZ", "abc...xyz"]
    `   # Pop and push the strings separately to the stack
     ‡  # Transliterate all uppercase letters to lowercase ones
        # (after which the result is output implicitly)

ÇIS.u32*+çJ saves a byte on your 12-byte version.

@Emigna Ah, smart. I had tried the .u32*+ approach like this: εÇy.u32*+ç]J, but unfortunately ç wraps the characters in a list, so an additional J or was required after theç`..

7 bytes (no case-altering built-ins)

@TheThonnu Thanks! And 26ô can actually be 2ä. :) ä (split into that many equal sized parts) is kinda the opposite of ô (split into parts of that size).

Nice: I was looking for that (as I knew it existed), but it's documented as "slice" not "split", so I couldn't find it :(

Perl: 24 characters
s/[A-Z]/chr 32+ord$&/ge

Sample run:
bash-4.1$ perl -pe 's/[A-Z]/chr 32+ord$&/ge' <<< 'Hello @ WORLD !'
hello @ world !

Hem, why chr ord ?  I'm pretty sure you won't learn anything in reading my answer ;-)

Amazing trick, @F.Hauri!

@nyuszika7h, the +1 is the -p command line parameter, not a newline.

Oh right, sorry.

javascript 80
"X".replace(/[A-Z]/g,function($){return String.fromCharCode($.charCodeAt()+32)})

(76 if you remove "X")
with prompt and alert - 92
alert(prompt().replace(/[A-Z]/g,function($){return String.fromCharCode($.charCodeAt()+32)}))

fiddle
thanks to @FireFly @some @C5H8NNaO4 and @minitech

Er, you'd need to wrap the second argument to replace with function($){return ...}, no?  By the way, the first param to the replacement function is the matched string, so you could drop the parens in the regex.

How would i go about running it,like this?

@C5H8NNaO4 str(code here)

I guess for a valid input you should at least assume,  it, to be predefined. costs only a char

@C5H8NNaO4 three (1)"(2)char(3)", its already pretty long, and the other answers dont have it. u can test this code if u want to see it run though "TeSt".replace(/[A-Z]/,function($){return String.fromCharCode($.charCodeAt()+32)})

I think all (or at least most) answers in here read from stdin and print to stdout. From what I gather the convention is to use prompt and alert for I/O in JS.

If you had tested your code, you would have fond that it only converts the first upper case character, not all of them. It's 92 characters, when following the rules: alert(prompt().replace(/[A-Z]/g,function(a){return String.fromCharCode(a.charCodeAt()+32)}))

You need a /g flag for this to work properly.

@some there is no rule which requires alert and prompt, but i will edit in that as well

@tryingToGetProgrammingStraight Somehow you must get the user supplied string into the program, and show the result. When code golfing in javascript the common way is to use prompt and alert. The rules doesn't say anything about it since the rules are language agnostic. If you look at the other answers you will see that they use the equivalent statements to do input/output in their respective languages. So why do you think that you don't need it when writing in javascript?

@some i figured that maybe it could be part of the program (as in my example), but since u commented i added one with prompt and alert as well, i dont see anything wrong with it now.

@tryingToGetProgrammingStraight Well, in that case I can write a program that is 0 characters long, pretending that everything else somehow is part of the program. Does that feel fair? Now your code works since it almost a verbatim copy of what I wrote, but you are using $ as a variable name. While it is legal, it is a bit confusing since $ mostly is used by libraries like jQuery. I also noticed that you didn't credit me or anyone else for finding bugs in your code.

It's 80 bytes, not 79.

JavaScript - 109 104 (ES6: 95)
Thanks to some for the corrected version.
a=prompt();for(b=[i=0];c=a.charCodeAt(i);)b[i++]=String.fromCharCode(c|(c>64&c<91)*32);alert(b.join(""))

The following works if the browser supports ES6 function expressions:
alert(prompt().split("").map(c=>String.fromCharCode(c.charCodeAt()|(c>"@"&c<"[")*32)).join(""))

The first code doesn't work (tested in FF and Chrome) because when trying to get a character after the length of the string, you get undefined and then c.charCodeAt() fails because undefined don't have charCodeAt. A working example 105 characters: a=prompt();for(b=[i=0];c=a.charCodeAt(i);)b[i++]=String.fromCharCode(c|(c>64&&c<91)*32);alert(b.join(''))

@some oops, I wonder how I came up with that snippet.. I'm pretty sure I tested that code, maybe I copied a non-working version in or something. Anyway, thanks for the correction.

Using a bitwise and instead of a logical one... nice!

An even more ES6 solution (79): L=s=>[String.fromCharCode(c.charCodeAt()|(c>"@"&c<"[")*32)for(c of s)].join(''). Usage: L('SoMeTeXt')

Nice! I'm not sure about making it a mere function though, since all other solutions are "proper" programs. Still, very nice use of for..of regardless.

DELPHI
const
  UpChars:set of AnsiChar = ['A'..'Z'];
var
  I: Integer;
begin
  SetLength(Result, Length(pString));
  for I := 1 to length(pstring) do
    Result[i] := AnsiChar((Integer(pString[i] in UpChars))*(Ord(pString[i])+32));
  WriteLn(Result);
end;

This is not golf. Don't you feel this piece is very different compared to others ?

@ray Golfing is about getting your code as short as possible. Delphi isnt a great language for golfing. I use delphi myself and even though there isnt a big chance I could win a golf with delphi, its still fun to challenge yourself.

Perl 18
s/[A-Z]/$&|" "/eg

Something like:
perl -pe 's/[A-Z]/$&|" "/eg'  <<<'are NOT allowed to: ToLower() in .NET, strtolower() in PHP'
are not allowed to: tolower() in .net, strtolower() in php

and
perl -pe 's/[A-Z]/$&|" "/eg' <<< "The input string Doesn't cOntaIn...( C0D3-@01F. ;-)"
the input string doesn't contain...( c0d3-@01f. ;-)

For @FireFly :
perl -pe 's/[A-Z]/$&|" "/eg' <<< "Doesn't this translate @ to \` and [\]^_ to {|}~DEL? "
doesn't ... @ to ` and [\]^_ to {|}~del?

no.
More generic: 18 chars anyway:

s/[A-Z]/$&|" "/eg

s/[A-Z]/$&^" "/eg

This wont change anything in state:
perl -pe 's/[A-Z]/$&^" "/eg' <<< "Doesn't ... @ to \` and [\]^_ to {|}~DEL? "
doesn't ... @ to ` and [\]^_ to {|}~del?

All work fine, but the advantage of changing | (or) by ^ (xor) is that the same syntax could be used for toLower, toUpper or swapCase:
toUpper:
perl -pe 's/[a-z]/$&^" "/eg' <<< "Doesn't ... @ to \` and [\]^_ to {|}~DEL? "
DOESN'T ... @ TO ` AND [\]^_ TO {|}~DEL?

and swapCase (18+1 = 19 chars):
perl -pe 's/[a-z]/$&^" "/egi' <<< "Doesn't ... @ to \` and [\]^_ to {|}~DEL? "
dOESN'T ... @ TO ` AND [\]^_ TO {|}~del?

I forgot +1 for -p sorry @manatwork

Doesn't this translate @ to backtick and [\]^_ to {|}~DEL? And therein lies the tricky part..

@FireFly No, $& have to match [A-Z].

Oh, my bad. Very cool, then!

x86-16 machine code, 15 bytes
Assembled:
ac3c 417c 063c 5a7f 020c 20aa e2f2 c3

Unassembled listing:
       _LOOP:
 AC         LODSB            ; load byte from [SI] into AL, advance SI
 3C 41      CMP  AL, 'A'     ; is char less than 'A'?
 7C 06      JL   _STORE      ; if so, do not convert
 3C 5A      CMP  AL, 'Z'     ; is char greater than 'Z'?
 7F 02      JG   _STORE      ; if so, do not convert
 0C 20      OR   AL, 'a'-'A' ; lowercase the char
       _STORE:
 AA         STOSB            ; store char to [DI], advance DI
 E2 F2      LOOP _LOOP       ; continue loop through string
 C3         RET              ; return to caller

Callable near function. Input string in DS:[SI], length in CX. Output string in ES:[DI].
Output from PC DOS test program:

where is the 14 byte count coming from?  the snippet is longer than that, even without comments... is 14 bytes the compiled program?

@Jonah The byte opcode is in the lefthand column, AC 3C 41, etc. I'll add the assembled hex byte code to the top for clarity. https://codegolf.meta.stackexchange.com/a/12340/84624

K (ngn/k), 19 17 bytes
{`c$x+32*~"A["'x}

Try it online!
Avoids using the floor builtin (_:).

~"A["' generate a bit mask with 1's in the positions in the input containing uppercase letters
32* multiply by 32, which calculates the offsets between uppercase and lowercase ASCII character codes
x+ add the offsets to the input (converting the string input to integers)
`c$ convert back to characters

R
71 characters:
chartr(paste(LETTERS,collapse=""),paste(letters,collapse=""),scan(,""))

83 characters:
a=as.integer(charToRaw(scan(,"")))
b=a%in%(65:90)
a[b]=a[b]+32
rawToChar(as.raw(a))

That's 86 characters - newlines count as 2 characters. (http://www.string-functions.com/length.aspx)

@Timtech: In R you can replace newlines in code by ; so no they count just for one character. It could be written: a=as.integer(charToRaw(scan(,"")));b=a%in%(65:90);a[b]=a[b]+32;rawToChar(as.raw(a))

Yes, now I realized. I read up on meta... seems that only on Windows that newlines are 2 characters (I was using a program to measure the length of my code).

Q, 18
.....
{x^ssr/[x]..Q`a`A}

PHP (42)
Run from the command line:
-R'echo@str_ireplace($a=range(a,z),$a,$argn);'

-R and the single quotes are not counted.

If you follow Gowtham's Peal solution, you would only count 42 characters.

@eisberg: Updated the score, leaving a 43-character version in the history in case of any dispute.

str_ireplace does case insensitive search, which is stretching the rules, if not breaking them.

@ugoren I do not think so. As it is clearly stated that only build in function changing the case are not allowed and this is ignoring the case not changing it.

Q (16)
.......
{x^(.Q.A!.Q.a)x}

Python (33)
If in doubt, use the shell.
import os;os.system('tr A-Z a-z')

Regrettably, this is still longer than Lego's solution.

+1 That is indeed not a Python built-in you are using. Only works on linux, but still very rule-bendy!!!

@LegoStormtroopr Works everywhere there is a tr command (which does the right thing) on the path of the invoked shell, I suppose.

PowerShell: 69 65 64
I've tried a half-dozen ways to get Replace to work the way I want it to without using the long [regex]::Replace syntax, but I haven't had any luck. If anyone else has an idea of what might work, please do suggest it.
Golfed code:
[regex]::Replace((read-host),"[A-Z]",{[char](32+[char]"$args")})

Changes from original:

Rearranged last argument so that [int] is no longer needed, per suggestion in comments.

Explanation:
(read-host) gets the user input.
[regex]::Replace(...) tells PowerShell to use RegEx matching to perform replacement operations on a string.
"[A-Z]" matches all uppercase letters.
{...} tells PowerShell to use a script to determine the replacement value.
[char]"$args" takes the current match and types it as an ASCII character.
32+ converts the character to an integer, representing the ASCII code, and increases the value by 32 - which would match ASCII code of the corresponding lowercase letter.
[char](...) takes the resulting value and converts it back to an ASCII character.
Demo of original:

(Current version tested - screenshot not yet posted.)

Haven't checked on how to get around that [regex]::Replace, but you can save 4 chars by changing [int] to +

Actually, the whole last argument can be rearranged to {[char](32+[char]"$args")}, which removes the need to explicitly cast to int and shaves off one more character

@goric Geez, why didn't I think of that already? Still learning, I guess.

k2, 15 bytes
I am super late to this one, but I found this cool anyway.
{_ci 32+_ic x}'

Also:
Pyth, 10 bytes
Doesn't really count because Pyth was created after this was posted. Still cool.
jkmC+32Cdw

PowerShell, 53 49 43 bytes
-4 bytes thanks @AdmBorkBork
-6 bytes thanks @Veskah
-join($args|%{[char](32*($_-in65..90)+$_)})

Try it online!

cool! ¯\_(ツ)_/¯

Splat it up for 43

Vim, 6 bytes
gUUg~~
Or, if allowed,
Vim, 3 bytes
guu

ggguG, I'd count that as built-in tho. :^)

Just for fun, because Java's my language.
Java - 162 175
Fixed for OP's updates.
class a{public static void main(String[]a){String b="";for(char c:new java.util.Scanner(
System.in).nextLine().toCharArray())b+=c>64&&c<91?(char)(c+32):c;System.out.print(b);}}

With line breaks and tabs
class a{

    public static void main(String[]a){
        String b="";
        for(char c:new java.util.Scanner(System.in).nextLine().toCharArray())b+=c>64&&c<91?(char)(c+32):c;
        System.out.print(b);
    }

}

See the question owner's recent comment.

manatwork is right. And in the challenge, I also wrote ASCII string, so it would be very unlikely that the input string would contain uppercase characters only.

Okay, will update when I get home.

@ProgramFOX Updated.

Python 3 - 70
Updated for OP's changes.
I'm a Python newbie, so any critique is welcome.
print("".join(chr(ord(c)+32) if 64<ord(c)<91 else c for c in input()))

I'm sorry, I had to say that you're not allowed to use a to-lower function on one character. Question updated.

Please see my recent comment: your code does only work if the input string contains only uppercase characters, but please note that it also contain other ASCII characters such as lowercase characters and numbers.

Okay, will update when I get home

@ProgramFOX Updated.

Jeff, check out @minitechs answer. You both have very similar approaches so you should be able to see how, and why his answer is shorter.

Javascript, 105
prompt().split("").map(function(a){c=a.charCodeAt(0);return String.fromCharCode(c|(c-64?32:0))}).join("")

 Actually ther was no output form specified, so run it in console
Yea, JavaScript really is verbose with charcode <-> string

c.charCodeAt() -- it defaults to 0 if an index is omitted.  Also, breaks on '@' I believe (it gets "lowercased" into backtick)

@FireFly Nice, Thanks!, ok i'll gonna fix it =)

Ruby: 66
def l(s)s.bytes.map{|b|(65..90).include?(b)?b+32:b}.pack('c*');end

C# - 108
class P{static void Main(string[]a){foreach(var c in a[0])System.Console.Write(
(char)(c>64&&c<91?c+32:c));}}

About 70 for just the method body.
Add 5 chars to include a LF/CR in the output:
class P{static void Main(string[]a){foreach(var c in a[0]+"\n")System.Console.Write(
(char)(c>64&&c<91?c+32:c));}}

A LINQ version would be shorter:
class P{static void Main(string[]a){a[0].Any(c=>System.Console.Write(
(char)(c>64&&c<91?32+c:c))is P);}}

(103) .. except that it requires using System.Linq; (total: 121).

Haskell - 58
p x|(elem x['A'..'Z'])=[x..]!!32|1<2=x
main=interact$map p

Perl, 9 + 1 (for -p flag) = 10
$_="\L$_"

\L was specifically asked about and allowed, because even though it's a built-in, it's not a function.

J, 39 30 bytes
(<&91*64&<)`(,:32+])}&.(a.i.])

-9 thanks to xash
Try it online!
Uses Item Amend } to choose which characters need to be lowercased and which passed through unaltered.
It applies this operation "under" conversion to ascii indexes &.(a.i.]) -- it first converts the string to the indexes of its characters, than applies the item amend transformation, then converts back.
The item amend transformation is defined by the gerund (<&91*64&<)`(,:32+]).  (,:32+]) defines the two possibilities: the input unaltered, or the the input shifted 32 places to the right, converting A to a, etc.  (<&91*64&<) determines which integers go into which transformation category: If an integer is greater than 64 and less than 91 -- ie, the integers corresponding to ABCDEFGHIJKLMNOPQRSTUVWXYZ -- it gets shifted by 32.

Monadic } works here neatly to choose between +32 and unaltered: Try it online!

Very nice.  I typically forget about item amend, but occasionally it's the perfect tool.

naz, 92 90 bytes
2x1v8a8m2x2v2d3m5s2x3v1x1f1r3x1v4e3x2v2g1o1f0x1x2f3x3v3l1o1f0x1x3f8a8a8a8a1o1f0x1x4f0a0x1f

Works for any null-terminated input string.
Try it online!
Explanation (with 0x instructions removed)
2x1v                   # Set variable 1 equal to 0
8a8m2x2v               # Set variable 2 equal to 64 ("@")
2d3m5s2x3v             # Set variable 3 equal to 91 ("[")
1x1f1r3x1v4e3x2v2g1o1f # Function 1
                       # Read a byte of input
                       # Goto function 4 if it equals variable 1
                       # Goto function 2 if it's greater than variable 2
                       # Otherwise, output it and call the function again
1x2f3x3v3l1o1f         # Function 2
                       # Goto function 3 if the register is less than variable 3
                       # Otherwise, output and jump to function 1
1x3f8a8a8a8a1o1f       # Function 3
                       # Add 32 to the register, output, and call function 1
1x4f0a                 # Function 4
                       # Add 0 to the register
1f                     # Call function 1

Vyxal, 2 bytes
⇧N

Try it Online!
This is the same as the 05ab1e answer but shorter because overloads.
Non-trivial version
kAkaĿ

Try it Online!
Funnily enough, I've used this before.
kAka    # Push "ABC...XYZ" and "abc...xyz"
    Ŀ   # Transliterate input with the above strings

Julia, 28 bytes
x->map(c->c+32('@'<c<'['),x)

Try it online!

Acc!!, 44 bytes
N
Count i while _ {
Write _+_/65*90/_*32
N
}

Outputs with a trailing newline. Try it online!
Explanation
The joke's on you, OP: Acc!! doesn't even have built-in to-lower functions... >:^D
N reads a byte from stdin into the accumulator; then we loop while that value is nonzero (i.e. we haven't yet reached end-of-input). We want to add 32 to the character code iff the input is an uppercase letter--that is, if its character code is between 65 and 90. Lacking comparison operators, we use int division:
Code range | _/65 | 90/_ | (_/65)*(90/_)
-----------|------|------|--------------
32-64      | 0    | >0   | 0
65-90      | 1    | 1    | 1
90-126     | >0   | 0    | 0

Now observe that _/65 will always be either 0 or 1 for all values of _ in the range we're interested in. So we can drop the parentheses: _/65*90/_ is equivalent to (_/65*90)/_, which is 90/_ if _ is >= 65 and 0 otherwise. Thus, our conditional lowercase formula is simply _+_/65*90/_*32. We write the corresponding character, read a new one, and loop.

JavaScript (Node.js), 53 bytes
s=>s.replace(/[A-Z]/g,x=>parseInt(x,36).toString(36))

Try it online!
From 12Me21's

Python - 96 94 82
for c in input():print(chr(ord(c)-65+97),end="")if c.isupper()else print(c,end="")

Ungolfed version:
for char in input():
    print(chr(ord(char) - (ord("A") - ord("a"))), end="") if char.isupper() \
    else print(char, end="")

You can replace ord("A") with 65 and ord("a") with 97 to save 12 bytes.

Because I felt like it (I know that I'm a bit late)
Java - 162
class a{public static void main(String[]a){for(char c:(new java.util.Scanner(System.in)).nextLine().toCharArray())System.out.print((char)((c>64&&c<91)?c+32:c));}}

expanded:
public class a{
    public static void main(String[] a) {
        for (char c : (new java.util.Scanner(System.in)).nextLine().toCharArray()) {
            System.out.print((char) ((c > 64 && c < 91) ? c + 32 : c));
        }
    }
}

Java - 119
class a{static{for(char c:(new java.util.Scanner(System.in)).nextLine().toCharArray())System.out.print((char)(c|32));}}

Works for every character except @ which becomes the back-tick (`), and the following (foo:bar for foo becomes bar) :
\:|
]:}
^:~
_:

Even though this isn't a true solution because it has 5 cases where it doesn't work, I thought it was very interesting. It takes the characters of the input and does a bitwise or with ' ' (c|32).
I discovered that c^32 swaps the case when the input is only letters while solving a project euler problem. I wondered what would happen in I changed the XOR to an OR.

Game Maker Language, 228
Make script/function s with this code, 53 characters:
a=argument0;b=string_replace_all(b,string_upper(a),a)

Then, use this 175 character code:
b=get_string('','')s('a')s('b')s('c')s('d')s('e')s('f')s('g')s('h')s('i')s('j')s('k')s('l')s('m')s('n')s('o')s('p')s('q')s('r')s('s')s('t')s('u')s('v')s('w')s('x')s('y')s('z')

The input (stored in variable b), is now lowercase.

JavaScript 124
The closest I got was 124 characters...
b=prompt();a=[];for(c=b.length;c--;)a[c]="@"<b[c]&"[">b[c]?String.fromCharCode(b[c].charCodeAt(0)+32):b[c];alert(a.join(""))

@Firefly, nice work with using the "map" command... I've yet to master it...

Powershell - 81 characters
Program:
param($s);[char[]]$s|%{if($_-lt90-and$_-gt64){$n+=[char](+$_+32)}else{$n+=$_}};$n

Example Usage:
.\lower.ps1 -s "TEST!"

Output:
test!

How it works:
It just adds 32 to the decimal value of the ASCII character, which is the lowercase version.
It only does this if it is within 64-90, which is all capital letters.

I don't know where you got 63 from. That's 81 characters. http://mothereff.in/byte-counter

Delphi XE3 (153 chars)
uses System.SysUtils;var u:string;i:int8;begin readln(u);for i:=1to Length(u)do if CharInSet(u[i],['A'..'Z'])then u[i]:=Chr(Ord(u[i])+32);writeln(u);end.

Not a winner but fun to do :)
with indent
uses
  System.SysUtils;
var
  u:string;
  i:int8;
begin
  readln(u);
  for i:=1to Length(u)do
    if CharInSet(u[i],['A'..'Z'])then
      u[i]:=Chr(Ord(u[i])+32);
    writeln(u);
end.

J 35
echo(+32*64&<*.95&>)&.(a.&i.)1!:1]3

Using the magical under &.. This looks up the ascii code, then adds 32 * the boolean inRange , where inRange is x>64 and x<91. The under operation automatically applies the inverse lookup afterwards, resulting in the wanted lowercase.
In action:
   echo(+32*64&<*.91&>)&.(a.&i.)1!:1]3
Hello World AZ!
hello world az!

Python 3, 78 bytes
t=input()
for c in t:
 x=ord(c)
 if 64<x<91:t=t.replace(c,chr(x+32))
print(t)

Japt, 7 5 bytes
;dBíC

Try it here

q 37 bytes
{$[x in .Q.A;x:(.Q.A!.Q.a)[x];x]}each

Explanation
$[x in .Q.A          // If the character is in the capitals list
  x:(.Q.A!.Q.a)[x]   // Create a key mapping between upper and lower case letters,
                     // and set x to it's pair
  x]}                // else, just return the character
  each               // apply to each character in string passed in

Example
q){$[x in .Q.A;x:(.Q.A!.Q.a)[x];x]}each "LoWersWFSfdgSA"
"lowerswfsfdgsa"

{x^.Q.a .Q.A?x} for 15 bytes.

Very nice. never use lookup, was surprised to see it index non-list members as just out-of-bounds (26).

JavaScript, 58 bytes
s=>s.replace(/[A-Z]/g,x=>(x.charCodeAt()-55).toString(36))

Forth (gforth), 55 bytes
: f 0 do dup i + c@ dup 65 91 within 32 * - emit loop ;

Try it online!
Explanation
Iterates through the string, for each character:

Gets the ascii value of the character
If between 65 and 90 (inclusive) add 32, else leave as is
Print the char corresponding to that value

Code Explanation
: f                   \ start new word definition
  0 do                \ start counted loop from 0 to string-length - 1
    dup i +           \ duplicate the string address and add the loop index
    c@                \ get the ascii char value at that address
    dup 65 91 within  \ check if value is between 65 and 90 (-1 = true, 0 = false)
    32 * -            \ multiply result by 32 and subtract from original number
    emit              \ output value
  loop                \ end loop
;                     \ end word definition

><>, 17 bytes
i::" @["{)${(**+o

Try it online!

JavaScript(ES6), 92/90 bytes
prompt().split('').map(x=>String.fromCharCode((y=x.charCodeAt(),y>64&y<91)?y+32:y)).join('')

l=a=>a.split('').map(x=>String.fromCharCode((y=x.charCodeAt(),y>64&y<91)?y+32:y)).join('')

Turn the input string into a char array, turn all uppercase letters into lowercase, and turn it back into a string.(Difference between uppercase letter and lowercase letter('a'-'A') is 32, 64 is '@', 91 is '['.)
If using alerts is required, that increases the characters by 7, which means it's 99 bytes.

FALSE, 29 bytes
[^$1_=~][$$64>\91>~&[32+]?,]#

Try it online!

///, 113 bytes
/~/\/\///Q/q~W/w~E/e~R/r~T/t~Y/y~U/u~I/i~O/o~P/p~A/a~S/s~D/d~F/f~G/g~H/h~J/j~K/k~L/l~Z/z~X/x~C/c~V/v~B/b~N/n~M/m/

Try it online!
Simply replaces all the uppercase characters with lowercase. Because there's no other way to take input in ///, it is hardcoded:
/~/\/\///Q/q~W/w~E/e~R/r~T/t~Y/y~U/u~I/i~O/o~P/p~A/a~S/s~D/d~F/f~G/g~H/h~J/j~K/k~L/l~Z/z~X/x~C/c~V/v~B/b~N/n~M/m/INPUT

batch 112 bytes
lower.bat
@Set "s=%~1"&@for %%c in (a b c d e f g h i j k l m n o p q r s t u v w x y z)do @Set "s=!s:%%c=%%c!"
@Echo(!s!

Notes:

requires cmd.exe's codepage to be 430 or 850, to change codepage, use: CHCP 430 or CHCP 850
Must be started in the directory containing lower.bat using:
Echo(Lower "String to convert"|CMD /V:On

C (gcc), 61 59 bytes
-2 thanks to @ceilingcat
main(i){while(i=getchar()-10)putchar(i+(i>54&i<81?42:10));}

Try it online!
Ungolfed:
int main(i){
    while((i=getchar()) != '\n') {
        if(i>64&i<91){ // uppercase ASCII range is 65-92
            putchar(i+32); // lowercase ASCII range is 97-122
        } else {
            putchar(i);
        }
    }
}

@ceilingcat I totally forgot to remove those braces when golfing it down

MATLAB/Octave, 29 bytes
@(x)char(x+32*(x>64).*(x<91))

Try it online!
Output to standard output variable Ans and written to command window.

mmo (MMIX executable), 112 bytes (28 tetras)
(jxd)
00000000: 98090100 98010001 00000100 e0002000  Ƭµ¢¡Ƭ¢¡¢¡¡¢¡ṭ¡ ¡
00000010: e3ff0140 00000300 58ff0002 00000000  ẉ”¢@¡¡¤¡X”¡£¡¡¡¡
00000020: 83010000 31ff0140 7502ff20 31ff015b  ³¢¡¡1”¢@u£” 1”¢[
00000030: 7002ff02 c0010102 a3010000 e3ff0140  p£”£Ċ¢¢£ɲ¢¡¡ẉ”¢@
00000040: 00000601 f1fffff3 00000000 20000000  ¡¡©¢ȯ””ṙ¡¡¡¡ ¡¡¡
00000050: 98020008 00000001 980a00ff 00000000  Ƭ£¡®¡¡¡¢Ƭ½¡”¡¡¡¡
00000060: 00000100 980b0000 00000000 980c0001  ¡¡¢¡Ƭ¿¡¡¡¡¡¡Ƭ€¡¢

Disassembly and explanation:
98090100 lop_pre 1,0                (mmo v1, 0 tetras)
98010001 lop_loc 0,1                (start loading at next tetra)
00000100 256                        (which is 256)
E0002000    SETH $0,#2000           (set $0 to address of data segment)
E3FF0140 0H SETL $255,2F            (set $255 to address of handle)
00000300    TRAP 0,Fread,StdIn      (read in one character)
58FF0002    PBNN $0,1F              (skip next instr if not EOF)
00000000    TRAP 0,Halt,0           (quit)
83010000 1H LDBU $1,$0,0            (read that byte in)
31FF0140    CMP  $255,$1,'@'        (compare with '@')
7502FF20    ZSP  $2,$255,#20        (if greater, then set $2 to 0x20)
31FF015B    CMP  $255,$1,'['        (compare with '[')
7002FF02    ZSN  $2,$255,$2         (unless less, clear $2)
C0010102    OR   $1,$1,$2           (or in $2)
A3010000    STBU $1,$0,0            (store it back)
E3FF0140    SETL $255,2F            (set $255 to address of handle)
00000601    TRAP 0,Fwrite,StdOut    (write that byte out)
F1FFFFF3    JMP  0B                 (loop back)
00000000                            (padding for alignment)
20000000 2H OCTA Data_Segment,1     (the handle)
98020008 lop_skip 8                 (slightly cheaper than two zero tetras)
00000001                            (end of handle)
980A00FF lop_post 255               (postamble, rG = 255)
00000000
00000100                            (start execution at location 256)
980B0000 lop_stab                   (begin symbol table)
00000000                            (no symbols)
980C0001 lop_end 1                  (symtab is one tetra long)

Thunno 2, 2 bytes
RP

Attempt This Online!
Port of user8777's Python answer.
Thunno 2, 4 bytes
kAẠṆ

Attempt This Online!
No uppercase/swap-case built-ins here.
Thunno 2, 12 bytes
ıDkAsƇ?C32+C

Attempt This Online!
No uppercase/swap-case/transliterate built-ins here.
Explanation
RP  # Implicit input
R   # Convert to uppercase
 P  # Swap the case of each character
    # Implicit output

kAẠṆ  # Implicit input
   Ṇ  # Transliterate the input
kA    # (from) the uppercase alphabet
  Ạ   # (to) the lowercase alphabet
      # Implicit output

ıDkAsƇ?C32+C  # Implicit input
ı             # Map over the input string:
 D            #  Duplicate it
    sƇ        #  Pop one copy, and check if it's in
  kA          #  the uppercase alphabet
      ?       #  If it is:
       C      #   Convert to codepoint
        32+   #   Add 32
           C  #   And convert to character
              #  Otherwise, the character stays on top
              # Implicit output, joined

Itr, 17 bytes
#µ»ä26¹64+=S32*+«
Reads string (surrounded by quotes) from standard input, prints the result to standard output
online interpreter
Explanation
#             ; read the string from standard input
 µ»   «       ; apply to each element
              ; implicitly print the result

ä             ; duplicate the character
 26¹64+       ; push the range from 65 to 90 ('A' through 'Z')
       =      ; vectorized equality check (of character and range)
        S     ; sum up the vector (1 if the char is in range, 0 otherwise)
         32*+ ; multiply by 32 and add to the character
```

bash: 11 characters?
$ i="This is A STRING"
$ echo ${i,,}
this is a string

It's a built'in toLower function!

@F.Hauri I assume that you'd need to add this comment on most of the answers in the thread.

@F.Hauri Wrong. Thats not a built-in *function*. That\s a built-in case-modification operator.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Converting integers to English words
The goal of this code golf is to convert integers to English words.
The program prompts for input. If this input isn't an integer, print NaN. If it is an integer, convert it to English words and print these words. Minimum input: 0 (zero). Maximum input: 9000 (nine thousand).
So, 5 returns five (case doesn't matter), and 500 returns five hundred or five-hundred (dashes don't matter).
Some other rules:
A one before hundred or thousand is optional: one hundred is correct, but hundred too (if the input is 100 of course).
The word and in for example one hundred and forty five is optional too.
Whitespace matters. So, for 500, five-hundred or five hundred is correct, but fivehundred is not.
Good luck!

There is an ungolfed answer here http://www.rgagnon.com/javadetails/java-0426.html .

This answer in SO does similar stuff but isn't code-golf.

Perl 281 bytes
print+0eq($_=<>)?Zero:"@{[((@0=($z,One,Two,Three,Four,Five,@2=(Six,Seven),
Eight,Nine,Ten,Eleven,Twelve,map$_.teen,Thir,Four,@1=(Fif,@2,Eigh,Nine)))
[$_/1e3],Thousand)x($_>999),($0[($_%=1e3)/100],Hundred)x($_>99),
($_%=100)>19?((Twen,Thir,For,@1)[$_/10-2].ty,$0[$_%10]):$0[$_]]}"||NaN

Newlines added for horizontal sanity. The above may be used interactively, or by piping it a value via stdin.
Works correctly for all integer values on the range [0, 19999], values outside this range exhibit undefined behavior. Non-integer values will be truncated towards zero, and as such, only values which are truly non-numeric will report NaN.
Sample usage:
for $n (14, 42, 762, 2000, 6012, 19791, 1e9, foobar, 17.2, -3) {
  print "$n: ", `echo $n | perl spoken-numbers.pl`, $/;
}

Sample output:
14: Fourteen
42: Forty Two
762: Seven Hundred Sixty Two
2000: Two Thousand
6012: Six Thousand Twelve
19791: Nineteen Thousand Seven Hundred Ninety One
1000000000: Thousand
foobar: NaN
17.2: Seventeen
-3: Nine Hundred Ninety Seven

"1000000000: Thousand "? And shouldn't 17.2 print "NaN"?

@DavidCarraher "... values outside this range exhibit undefined behavior. Non-integer values will be truncated towards zero, and as such, only values which are truly non-numeric will report NaN."

I'm not a Perl expert, so I ask this question: does this program prompt for input?

@ProgramFOX I have updated it to read a value from stdin (if run interactively, it will prompt the user for a value), instead of as a function.

JavaScript (375)
Probably a terrible attempt, but anyway, here goes...
alert(function N(s,z){return O="zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir,,fif,,,eigh,,,,twen,,for".split(","),(z?O[s]||O[s-10]||O[s-20]:s<13?N(s,1):s<20?N(s,1)+"teen":s<100?N(a=20+(s/10|0),1)+"ty"+(s%10?" "+N(s%10):""):s<1e3?N(s/100|0)+" hundred"+(s%100?" "+N(s%100):""):s<1e5?N(s/1e3|0)+" thousand"+(s%1e3?" "+N(s%1e3):""):0)||NaN}(prompt()))

Pretty-printed (as a function):
function N(s,z) {
  return O = "zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir,,fif,,,eigh,,,,twen,,for".split(","),
      (z? O[s] || O[s-10] || O[s-20]
       : s < 13?  N(s,1)
       : s < 20?  N(s,1) + "teen"
       : s < 100? N(a=20+(s/10|0),1) + "ty" + (s%10?" "+N(s%10):"")
       : s < 1e3?  N(s/100|0) +  " hundred" + (s%100?" "+N(s%100):"")
       : s < 1e5?  N(s/1e3|0) + " thousand" + (s%1e3?" "+N(s%1e3):"") : 0) || NaN
}

Sample conversion (note that it even outputs NaN when out of bounds, i.e. invalid input):
540: five hundred forty
4711: four thousand seven hundred eleven
7382: seven thousand three hundred eighty two
1992: one thousand nine hundred ninety two
hutenosa: NaN
1000000000: NaN
-3: NaN

+1 its quite difficult to do better in a language like javascript. (you can remove the space in N(s,z) {return to save 1 char)

Oh, haha, must've missed that one. I also seem to have missed a bunch of chars in the O string. I'll fix that..

Mathematica 60 57
f = ToString@#~WolframAlpha~{{"NumberName", 1}, "Plaintext"} &

Usage:
f[500]

five hundred

Edit:
InputString[]~WolframAlpha~{{"NumberName", 1}, "Plaintext"}

This doesn't really answer the question. I said that the user has to input a number (using the command line, or a prompt box for example), and then your program should output the words (on the command line, or in a message box for example). Your code is just a function to convert it, and your program doesn't ask for input.

@ProgramFOX it says 'The user inputs something'.  That does not mean 'The program prompts for input'.

@MrZander: Well, 'The program prompts for input' was actually what I meant. I update my question, but of course, it would be unfair if I wouldn't upvote alephalpha's answer, so he got my +1

Lisp, 72 56 characters
I realize 1) that this is old, and 2) that it relies entirely on the standard library to function, but the fact that you can get the c-lisp printing system to do this kind of thing has always impressed me.  Also, this does in fact take the input from a user, convert it, and print it.
(format t "~:[NaN~;~:*~r~]" (parse-integer (read-line) :junk-allowed t))

It totals 72 characters.

:junk-allowed causes parse-integer to return nil on failure instead of raising an error.
~:[if-nil~;if-non-nill] conditional predicated on nil, handles NaN where necessary
~:* backs up the argument interpretation to re-consume the input
~r prints the number as an english word string, as requested, except with full corrected punctuation

Sample:
17823658
seventeen million, eight hundred and twenty-three thousand, six hundred and fifty-eight

192hqfwoelkqhwef9812ho1289hg18hoif3h1o98g3hgq
NaN

Lisp info mainly from Practical Common Lisp.
Edit, golfed properly down to 56 characters
(format t "~:[NaN~;~:*~r~]"(ignore-errors(floor(read))))

This version works rather differently. Instead of reading a line and converting it, it invokes the lisp reader to interpret the input as a lisp s-expression, attempts to use it as a number, and if any errors are produced ignores them producing nil to feed the format string conditional.  This may be the first instance I've seen of lisp producing a truly terse program... Fun!

(read) Invokes the lisp reader/parser to read one expression from standard input and convert it into an appropriate object
(floor) attempts to convert any numeric type into the nearest lower integer, non-numeric types cause it to raise an error
(ignore-errors ...) does what it says on the tin, it catches and ignores any errors in the enclosed expression, returning nil to feed the NaN branch of the format string

It's certainly no problem that the question old :) I edited your answer to include the language name and the character count in a header.

Thank you for the edits, I haven't gotten the Stack* syntax for these things down yet.  Went back in and fixed a mistake I made in the description of the conditional in the format string as well.

PHP, 327 310 308 bytes
<?$a=['',one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir,0,fif,0,0,eigh];echo($n=$argv[1])>999?$a[$n/1000].' thousand ':'',$n%1000>99?$a[$n/100%10].' hundred ':'',$n?($k=$n%100)<20?($a[$k]?:$a[$k%10]).[teen][$k<13]:[2=>twen,thir,'for',fif,six,seven,eigh,nine][$k/10].'ty '.$a[$k%10]:zero;

takes the number as parameter, works for 0<=n<=12999
breakdown
// define names
$a=['',one,two,three,four,five,six,seven,eight,nine,
    ten,eleven,twelve,thir,0,fif,0,0,eigh];
// print ...
echo
    ($n=$argv[1])>999?$a[$n/1000].' thousand ':'',                  // thousands
    $n%1000>99?$a[$n/100%10].' hundred ':'',                        // hundreds
    $n?
        // if remains <20:
        ($k=$n%100)<20?
            ($a[$k]?:$a[$k%10]) // no value at index (0,14,16,17,19)? value from index%10
            .[teen][$k<13]      // append "teen" for $k>12
        // else:
        :[2=>twen,thir,'for',fif,six,seven,eigh,nine][$k/10].'ty '  // tens
        .$a[$k%10]                                                  // ones
    // "zero" for $n==0
    :zero
;

SAS, 70 characters
data;window w n;display w;if n=. then put 'NaN';else put n words.;run;

The window and display statements open up the SAS command prompt. Input for n goes on line 1. This takes advantage of the SAS format words. which will print the number as a word or series of words with "and", " ", and "-" as appropriate.

PHP
777 characters
This is definitely a terrible attempt, but you can't accuse me of taking advantage of any loopholes, plus it's a very lucky number. Thanks to ProgramFOX for the tip.
<?php $i=9212;$b = array('zero','one','two','three','four','five','six','seven','eight','nine');$t='teen';$c = array('ten','eleven','tweleve','thir'.$t,$b[4].$t,'fif'.$t,$b[6].$t,$b[7].$t,$b[8].$t,$b[9].$t);$d = array('','','twenty','thirty','fourty','fifty','sixty','seventy','eighty','ninety');$e='hundred';$f='thousand';$j=str_split($i);if (strlen($i)===1){$a=$b[$i];}elseif (strlen($i)===3){$k=1;$a=$b[$j[0]].' '.$e.' '.x($j,$k);}elseif (strlen($i)===4){$k=2;$a=$b[$j[0]].' '.$f.' '.$b[$j[1]].' '.$e.' '.x($j,$k);}elseif (substr($i, -2, 1)==='1'){$a=$c[$j[1]];}else{$a=$d[$j[0]].' '.$b[$j[1]];}$a = str_replace('zero hundred','',$a);echo $a;function x($j,$k){global $i, $b, $c, $d;if (substr($i, -2, 1)==='1'){return $c[$j[$k+1]];}else{return $d[$j[$k]].' '.$b[$j[$k+1]];}}

Long hand
<?php
// Input
$i=9212;
// 0-9
$b = array('zero','one','two','three','four','five','six','seven','eight','nine');
// 10-19 (Very tricky)
$t='teen';
$c = array('ten','eleven','tweleve','thir'.$t,$b[4].$t,'fif'.$t,$b[6].$t,$b[7].$t,$b[8].$t,$b[9].$t);
// Left digit of 20-99
$d = array('','','twenty','thirty','fourty','fifty','sixty','seventy','eighty','ninety');
// Hundreds
$e='hundred';
// Thousands
$f='thousand';
// Split input
$j=str_split($i);
// 1 digit inputs
if (strlen($i)===1){$a=$b[$i];}
// 3 digit input
elseif (strlen($i)===3){$k=1;$a=$b[$j[0]].' '.$e.' '.x($j,$k);}
// 4 digit input
elseif (strlen($i)===4){$k=2;$a=$b[$j[0]].' '.$f.' '.$b[$j[1]].' '.$e.' '.x($j,$k);}
// 10-19
elseif (substr($i, -2, 1)==='1'){$a=$c[$j[1]];}
// 20-99
else{$a=$d[$j[0]].' '.$b[$j[1]];}
// Fix for thousand numbers
$a = str_replace('zero hundred','',$a);
// Result
echo $a;
// Abstracted function last 2 digits for 3 and 4 digit numbers
function x($j,$k){
    global $i, $b, $c, $d;
    // 10-19
    if (substr($i, -2, 1)==='1'){return $c[$j[$k+1]];}
    // 20-99
    else{return $d[$j[$k]].' '.$b[$j[$k+1]];}
}

I think you can shorten your code by creating arrays like this: array('zero','one','two').

@ProgramFOX or even ['zero','one','two'] (php 5.4+). And if you don't mind E_NOTICE, [zero,one,two] would work as well.

I should update it, but 777 is such a lucky number.

+1 for your efforts. PHP is tragically underrepresented in code golf.

Python 2.x - 378
Derivative of Fireflys answer, although by changing P to include million or trillions, etc..  it could recursively be used for any range of positive numbers. This also supports values up to 999,999
O=",one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir,,fif,,,eigh,,,,twen,thir,for,fif,,,eigh,".split(",")
P=",thousand".split(',')
def N(s,p=0):
 h,s=divmod(s,1000);x=N(h,p+1)if h>0 else" "
 if s<20:x+=O[s]or O[s-10]+["","teen"][s>12]
 elif s<100:x+=(O[s/10+20]or O[s/10])+"ty"+N(s%10)
 else:x+=N(s/100)+"hundred"+N(s%100)
 return x+" "+P[p]
print N(input())

Sample test (input is <<<, output is >>>):
<<< 1234
>>> one thousand two hundred thirty four

<<< 999999
>>>  nine hundred ninety nine   thousand nine hundred ninety nine

Although, if someone can explain this odd "buffer underflow" issue I have, that'd be swell...
<<< -1
>>>  nine hundred ninety nine

<<< -2
>>>  nine hundred ninety eight

print divmod(-2,1000) #-> (-1, 998)

Oh of course. I was thinking it might take an absolute value or something. But there is -1*1000 and a "remainder" of 998.

SmileBASIC, 365 Three Hundred Forty Seven bytes
DIM N$[22]D$="OneTwoThreeFourFiveSixSevenEightNineTenElevenTwelveThirFourFifSixSevenEighNineTwenFor
WHILE LEN(D$)INC I,D$[0]<"_
INC N$[I],SHIFT(D$)WEND
INPUT N
W=N MOD 100C%=N/100MOD 10M%=N/1E3T=W<20X=W/10>>0?(N$[M%]+" Thousand ")*!!M%+(N$[C%]+" Hundred ")*!!C%+(N$[X+10+(X==2)*8+(X==4)*7]+"ty "+N$[N MOD 10])*!T+N$[W*T]+"teen"*(T&&W>12)+"Zero"*!N

There's a trailing space if the last one or two digits are 0.

Vyxal, 11 bytes
⌈≠[`NaN`|∆ċ

Try it Online!
Easy win when it's a built-in :p

@Lynn now it does

If you use 2.16.x or something kn works?

MOO - 55 83 bytes
x=$code_utils:toint(read(p=player));p:tell(x==E_TYPE?"NaN"|$string_utils:english_number(x))

Note: this code does not print any prompt to the standard output.
As a bonus, this code can handle any number withing the bounds of the moo language (2147483647--2147483648).

Wolfram Language 27 40 bytes
Making use of the native function, IntegerName,
 Check[Input[]~IntegerName~"Words","NaN"]

The above prompts for user input.  The present implementation returns "NaN" if the user enters anything other than an integer.

Some examples (with pre-set inputs):
 Check[243~IntegerName~"Words","NaN"]

two hundred forty-three

 Check[1234567890~IntegerName~"Words","NaN"]

one billion, two hundred thirty-four million, five hundred
  sixty-seven thousand, eight hundred ninety

 Check["abc"~IntegerName~"Words","NaN"]

NaN

Python 2, 333 bytes
def f(n):S=str.split;D=S('z one two three four five six seven eight nine');K=' fif six seven eigh nine';k=n/1000;n,m=n/100%10,n%100;e,d=m/10,m%10;return' '.join([k and f(k),'thousand']*(k>0)+[D[n],'hundred']*(n>0)+([S('ten eleven twelve thir four'+K)[d]+'teen'*(d>2)]if 9<m<20else[S('twen thir for'+K)[e-2]+'ty']*(e>0)+[D[d]]*(d>0)))

Try it online!
This is good for 1 to 999,999, inclusive.

Pyth, 239 242 bytes
L:rjdb6"  +"dAm+cd;"nine"," one two three four five six seven eight""  twen thir for fif six seven eigh"|y_.ey+Wk.e?Y?thZjd,?hZ+@HhZ"ty"""@GeZ@+c"ten eleven twelve"d+R"teen"+c"thir four"d>H5eZ?hZ+@GhZ" hundred"""c.[03_b]1"thousand"c_jQT3"zero

Input is an integer in range [0-999,999]. Try it online here. Explanation pending.
Previous version, very similar operation, but doesn't support 0:
L:rjdb6"  +"dJc" one two three four five six seven eight nine"dKc"  twen thir for fif six seven eigh nine"dy_.ey+Wk.e?Y?thZjd,?hZ+@KhZ"ty"""@JeZ@+c"ten eleven twelve"d+R"teen"+c"thir four"d>K5eZ?hZ+@JhZ" hundred"""c.[03_b]1"thousand"c_jQT3

Explanation of previous version:
Implicit: Q=eval(input()), d=" "

Step 1: output formatting helper function
L:rjdb6"  +"d
L               Define a function, y(b):
   jdb          Join b on spaces
  r   6         Strip whitespace from beginning and end
 :              In the above, replace...
       "  +"    ... strings of more than one space...
            d   ... with a single space

Step 2: Define number lookup lists
Jc"..."dKc"..."d
  "..."            Lookup string
 c     d           Split the above on spaces
J                  Store in J - this is list of unit names
        Kc"..."d   As above, but storing in K - this is list of tens names, without "ty"

Step 3: Bringing it all together
y_.ey+Wk.e?Y?thZjd,?hZ+@KhZ"ty"""@JeZ@+c"ten eleven twelve"d+R"teen"+c"thir four"d>K5eZ?hZ+@JhZ" hundred"""c.[03_b]1"thousand"c_jQT3
                                                                                jQT    Get digits of Q
                                                                                _       Reverse
                                                                                c    3   Split into groups of 3
  .e                                                                                Map the above, element as b, index as k, using:
                                                                                _b                       Reverse the digits in the group
                                                                                .[03                         Pad the above on the left with 0 to length 3
                                                                                c      ]1                     Chop at index 1 - [1,2,3] => [[1],[2,3]]
        .e                                                                                Map the above, element as Z, index as Y, using:
          ?Y                                                                                If second element in the group (i.e. tens and units):
            ?thZ                                                                                If (tens - 1) is non-zero (i.e. 0 or >=2):
                   ?hZ                                                                                If tens is non-zero:
                       @KhZ                                                                                Lookup in tens names
                      +    "ty"                                                                                Append "ty"
                                                                                Else:
                               ""                                                                                Empty string
                  ,                                                                                Create two-element list of the above with...
                                 @JeZ                                                                                ... lookup units name
                jd                                                                                Join the above on a space - this covers [0-9] and [20-99]
                                                                                Else:
                                                                     c"thir four"d                                                             ["thir", "four"]
                                                                    +             >K5                                                          Append last 5 element of tens names ("fif" onwards)
                                                            +R"teen"                                                                           Append "teen" to each string in the above
                                      +c"ten eleven twelve"d                                                                                Prepend ["ten", "eleven", "twelve"]
                                     @                                               eZ                                                        Take string at index of units column - this covers [10-19]
                                                                                Else: (i.e. hundreds column)
                                                                                ?hZ                                                   If hundreds column is non-zero:
                                                                                @JhZ                                                Lookup units name
                                                                                +    " hundred"                                      Append " hundred"
                                                                                ""                                  Else: empty string
                                                                                Result of map is two element list of [hundreds name, tens and units name]
      Wk                                                                                If k is nonzero (i.e. dealing with thousands group)...
     +                                                                                "thousand"           ... Append "thousand"
    y                                                                                Apply output formatting (join on spaces, strip, deduplicate spaces)
                                                                                Result of map is [units group string, thousands group string]
 _                                                                                Reverse group ordering to put thousands back in front
y                                                                                Apply output formatting again, implicit print

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
A simple logic gate calculator
Your mission, if you choose to accept it, is to construct a simple truth evaluator for the following logical operators:
----------------------------------------------------------------------------------
  Logical Name          |  Gate Name   |  Symbol  |  Symbol Name  |  Truth Table
----------------------------------------------------------------------------------
  Identity              |  is          |          |  (none)       |  10
  Negation              |  not         |    ~     |  tilde        |  01
  Conjunction           |  and         |    &     |  ampersand    |  1000
  Disjunction           |  or          |    |     |  pipe         |  1110
  Negative Conjunction  |  nand        |    ^     |  caret        |  0111
  Joint Denial          |  nor         |    v     |  "vee"        |  0001
  Exclusive Disjunction |  xor         |    x     |  "ecks"       |  0110
  Equivalence           |  equals/xnor |    =     |  equals       |  1001
  Implication           |  implies     |    >     |  greater than |  1011

Truth tables are in the following order:

1 1
1 0
0 1
0 0

Input will come as a simple string of 0, 1, and the symbol.  You can either accept input as a parameter or read it from the user on stdin.  Here are some sample input/output pairs:
Input: 1
Output: 1

Input: ~1
Output: 0

Input: 0|1
Output: 1

Input: 1>0
Output: 0

The unary operator (negation) will always appear before the boolean value, while the binary operators will always appear between the two boolean values.  You can assume that all input will be valid.   Strings are regular ASCII strings.
If you prefer, you can use T and F rather than 1 and 0.  -6 to your character count if you support both.
This is code-golf: shortest code in any language wins!

I believe ^'s symbol name should say caret.

@FireFly Haha, you're right.  Too close to lunch!  Thanks.

APL (45 - 6 = 39)
⍎(1+9≠L)⌷¨↓⍉Z⍪⍉⍪'10∧∨⍲⍱≠≤*'[L←'TF&|^vx>'⍳Z←⍞]

Supports T and F as input but will always output 0 or 1.
Explanation:

Z←⍞: read a line and store it in Z
L←'TF&|^vx>'⍳Z: get the index in 'TF&|^vx>' for each character in Z, giving 9 if the character is not in 'TF&|^vx>'.
'10∧∨⍲⍱≠≤*'[...]: find the corresponding character in '10∧∨⍲⍱≠≤*'. (So characters that weren't in the first list become *).
↓⍉Z⍪⍉⍪: make this into a matrix, put the original (Z) on top of it, and split it into a list of strings, where the first character is the original and the second character is its translation, if any.
(1+9≠L)⌷¨: for each of these strings, get the first character if there was no translation (if L=9 in that place) and the second character if there was.
Example: if the input had been T|0, we would have 1∨0 by now which is the corresponding APL expression
⍎: eval

Note: ~ and = already do the right thing so they don't need to be replaced by anything.

Very nice! This is a translate-to-APL-and-eval approach, right? I was pondering a gerund-based approach in J, but I don't know how to cleverly split up the operands. :\

Why do matrix manipulation when you can simply add translation rules for no-change characters like ⍎'1010~∧∨⍲⍱≠=≤'['10TF~&|^vx=>'⍳⍞]? (Score 33-6=27)

C - 165 127
That was fun!  Plain lookup table relying on a fixed offset for the lookup.
main(){
  char*s="100011001110110v& x = |^> /~",
       t[6]="0/xxx",
      *u= strchr((gets(t+2),t),0)-3;
  putchar(strchr(s,u[1])[*u*2+u[2]-159]);
}

For some reason gets doesn't get implicitly declared, so when I removed the include I had to change gets(t+2) to (gets(t+2),t) (or similarly elsewhere, costing as much).

Explanation
First of all, since the truth tables for the operators have plenty of overlapping characters we wish to store the lookup tables in a way so that we allow overlap.  Here's how I chose to store them:
v    &    x    =    |    ^    >       ~     (operation)
1000 0001 0110 1001 0111 1110 1101 01 10    (truth table [order 00,01,10,11])
0    1    3    5    7    8    9    B  D     (offset in LUT below)

0123456789ABCDE   (offsets)
100011001110110   (values)

Next, we want to map operator symbols to these offsets.  We do this by storing the operator symbols in the same string at a fixed offset from the LUT data (namely, 16 characters later, i.e. directly after the LUT data).  The lookup process is "find operator in s, subtract 16, add left*2+right (left/right operand). For the lookup of the empty "identity operation", due to how the input is fetched the operator in this case will resolve to whatever t[1] is initialised to--in our case /. Thus, we use / as the lookup table key to represent the identity operation. When we process the unary ~ operation "left" (for the lookup calculation mentioned earlier) is always this same /
.  / happens to be one less than 0 ASCII-wise, meaning when we compensate for ASCII digits \ will represent -1. The slash in the lookup table key area (second-to-last character in s, that is) is positioned to compensate for this.
Next up, input handling.  The input has dynamic length, but it'd be easier if we have specific static names for the left operand, operator and right operand, regardless of input.  If we pretend that we could read the input right-to-left, this would basically happen automagically--the right operand is always the rightmost character, the operator (if present) is second-to-rightmost, the left operand (if present) is third-to-rightmost.  In order to be able to index the string like this, we use strchr in order to locate the \0 terminator (- 3 to simplify indexing).  This shows why t[0] and t[1] become the left operand/operator respectively when the input is 1 or 2 characters.
Putting it together, the output would be putchar(strchr(s,u[1])[(u[0] - '0')*2 + (u[2] - '0') - 15]), but some refactoring and constant folding instead gets us the shorter putchar(strchr(s,u[1])[u[0]*2+u[2]-159]).

Could you explain how that works?

The truth table overlap was a brilliant idea.  Would've never thought of that myself. :)

Also the reading right-to-left.  I knew the variable length input and positioning would pose a challenge, and that's a great way to solve it.  Really excellent out-of-the-box thinking.  Want to come work on my development team?  Haha

I think more answers should have explanations like this. Helps those of us who are still learning a considerable bit! (And by those who are still learning pretty much means everyone)

@agweber: That's good to hear, I was a bit worried about my explanation. And yes, probably everyone here is in a "still learning" phase.. well, at least I know I am.

Tcl, 212 208-6 = 202
proc o n\ e {proc $n a\ b expr\ $e}
o > {$a<=$b}
o v {!($a|$b)}
o x {$a^$b}
o ^ {!($a&$b)}
namespace pat tcl::mathop
lmap o\ b [lassign [split [string map {~0 1 ~1 0} $argv] {}] a] {set a [$o $a $b]}
puts $a

Ungolfed:
# Defines an operator
proc operator {name expression} {
    proc $name {a b} "expr $expression"
}
operator > {$a<=$b}
operator v {!($a|$b)}
operator x {$a^$b}
operator ^ {!($a&$b)}
# Call the commands in ::tcl::mathop if the command is not in the global namespace
namespace path tcl::mathop
# lmap instead foreach
# assume that we only got 1 argument.
foreach {op b} [lassign [string map {{~ 0} 1 {~ 1} 0} [split $argv {}]] a] {
   set a [$op $a $b]
}
puts $a

I think the foreach line needs some explanation:

split $argv {} splits the input string (it is actually a list, but code-golf) into it's characters.
string map {{~ 0} 1 {~ 1} 0} ... takes a string and replaces ~ 0 with 1 and ~ 1 with 0
lassign ... a takes the first element of the list and assigns it to the variable a, returns the rest.
foreach {op b} ... {code} walks over the list and takes 2 elements each time: op and b
set a [$op $a $b] executes the command in the variable op, stores the result in a

JavaScript - 107 105 characters
alert((x=eval(prompt().replace(/v/,'|~').replace(/\^/,'&~').replace(/x/,'^').replace(/=/,'==')))!=-1?x:0)

Haha, nice.  That's handy.  Didn't even think of eval() when I made this up. Just give me a bit to get home and test it.

nand = &~ and nor = |~?

@Johannes: It is not really &~ and |~, but NAND is just the inverse of AND. So, inversing one of the bits does invert the result too.

Befunge-98 - 104 101 98-6 72
...because every task needs an esolang solution.. translation of my C implementation, but processing characters one at a time instead.
#v~
2_vp5a00+*2%2\p10\%
0:<+1_v#-g5\g1
1_|#:\</2\-
.@>2%
 v   ~x^&=.>  |

Fun fact: change the @ to a,$ and you get a fancy neverending REPL instead (though, if you do this you'll notice that identity is actually "repeat last command with lhs=0 and rhs=input", which just happens to default to identity). The REPL is no more.
Ungolfed (earlier version):
v10001100111011v& x = |^>~
  $       1111111111222222
 1234567890123456789012345

 [read input]
> ~ :a- #v_   $ 21g " "- + 0g , @

v p11:   <
   ↑save chr

0 ←lup   [traverse LUT]
> 1+  :11g  \0g -! #v_
 v                  <
    lup chr acc
v>  :3` #v_  $"0"-\2*+

               v>   . , a,
 v       <
v> 9+9+ 21p $

Edit: inspired by @jpjacobs' solution, I now rely on the position of characters in the LUT to represent truth tables.  E.g., | is on position 11102 = 14 because this corresponds to the truth table for |.

That is crazy. Ok, every solution in befunge is crazy.

J - 6567-6=61
No more the b. Adverb.
Without counting the assignment of the function: 67 characters for the TF version, 63 for the non-TF version:
lgcTF =:".@({&('*+-+-<*01',.3 6#'.:')"1@n^:(9>n=:'&|~xv>^FT'&i.)@{.&.>&.;:)
lgc   =:".@({&('*+-+-<*',.3 4#'.:')"1@n^:(7>n=:'&|~xv>^'&i.)@{.&.>&.;:)

LgcTF handles both 0 and 1 as well as T and F.
Supports all of J's syntax in terms of trains, parenthesis, and evaluates strictly right to left (no other precedence rules).
All characters not in the operator list + Z can not be used, others will act as in standard J (including variables).
Usage:
NB.Assign TF anyhow
T=:1 [ F=: 0
lgc 'T & F'
0
lgc ' T ~@& F' NB. negation after and = nand
NB. make a truth table
d=: 0 1
lgc 'd ~@|/ d'
1 0
0 0
NB. and so on...

Postscript 263
Firefly's idea translated to Postscript.
{(0/xxx)dup 2 3 getinterval(%lineedit)(r)file exch
readstring pop length 1 sub 3
getinterval(100011001110110v& x = |^> /~)dup
2 index 1 1 getinterval search pop exch pop exch pop
length 3 2 roll{}forall exch pop exch 2 mul add 159 sub add
1 getinterval =}loop

Indented:
%!

{
    (0/xxx) dup 2 3 getinterval
    (%lineedit)(r)file exch % (0/xxx) file (xxx)
    readstring pop
    length % (0/xxx) len(x|xx|xxx)
    1 sub 3 getinterval % (0/x)|(/xx)|(xxx)
    (100011001110110v& x = |^> /~) dup
    2 index 1 1 getinterval search pop % (0/x)|(/xx)|(xxx) s post match pre
    exch pop exch pop % (xxx) s pre
    length
    3 2 roll {} forall exch pop % s len(pre) u_0 u_2
    exch 2 mul add 159 sub add % s ind
    1 getinterval
    = flush
} loop

Befunge-93, 86 characters
Works by hashing the second symbol of the input (finding a function that was both compact and avoided collisions was some work) for a y coordinate, and taking the first and third symbols each modulo 2 as the two least significant bits of the x coordinate, then retrieving whatever value is at the indicated position. A better hash function or more compact method of storing/addressing the truth tables are just two possible ways one could cut down on the length.
~~~\:8/\5%:++00p2%\2%2*+00gg,@
0 1

1001
0001
1101
1

0
0110

1110
1000

0111

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Sorting a list of strings without using any built-in sort method
The goal of this Code Golf is to create a program that sorts a list of strings (in ascending order), without using any built-in sort method (such as Array.Sort() in .NET, sort() in PHP, ...).  Note that this restriction excludes using a built-in method that sorts an array descending, and then reversing the array.
Some details:

Your program should prompt for input, and this input is a list of strings containing only ASCII lower-case alphabetic characters a-z, comma-separated without spaces. For example:
code,sorting,hello,golf

The output should be the given list of strings, but sorted in ascending order, still comma-separated without spaces. For example:
code,golf,hello,sorting

GolfScript, 26 25 bytes
","/.,{{.2$<{\}*}*]}*","*

Straightfoward implementation of Bubble Sort.
Try it online in Web GolfScript.
How it works
","/     # Split the input string at commas.
.,       # Get the number of chunks.
{        # Do that many times:
  {      #   Reduce; for each element but the first:
    .2$< #     Push 1 if the last two strings are in descending order, 0 if not.
    {\}* #     Swap these strings that many times.
  }*]    #   Collect the strings dumped by reduce in an array.
}*       #
","*     # Join, separating by commas.

Nice! Accepting this one as answer because it's shorter than the currently accepted one.

Ruby 76 54 51 chars
x=gets.scan /\w+/;$><<x.dup.map{x.delete(x.min)}*?,

Very nice, bogosort :D

Wow, now it's even more interesting! I had to look at this for a while before I realized what was happening. I suppose now it's a slight variation of selection sort :P

Since the items are guaranteed to be alpha characters: x=gets.scan /\w+/

k (16 chars)
Probably doesn't really live up to the spirit of the problem. In k, there is no built in sort operator. <x returns a list of indices of items in x in sorted order.
{x@<x}[","\:0:0]

Well, this is a kind of built-in sorting, so unfortunately, I can't mark this as answer. I like the idea, however, so +1!

SED, 135
s/.*/,&,!,abcdefghijklmnopqrstuvwxyz/;:;s/\(,\([^,]*\)\(.\)[^,]*\)\(.*\)\(,\2\(.\)[^,]*\)\(.*!.*\6.*\3\)/\5\1\4\7/;t;s/^,\(.*\),!.*/\1/

Based on my previous sorting entry

Ruby, 99 chars (Gnome sort)
a=gets.scan /\w+/
p=1
while a[p]
a[p]>a[p-1]?p+=2:(a[p],a[p-1]=a[p-1],a[p])
p-=1if p>1
end
$><<a*?,

This just barely beats my bubble sort implementation:
Ruby, 110 104 101 chars (Bubble sort)
s=gets.scan /\w+/
(z=s.size).times{(0..(z-2)).map{|i|s[i],s[i+1]=s[i+1],s[i]if s[i]>s[i+1]}}
$><<s*?,

This does list.length iterations, because worst-case scenario takes list.length - 1 iterations and one more really doesn't matter, and saves 2 chars.
Just for fun, a Quicksort version:
Ruby, 113 chars (Quicksort)
q=->a{if a[1]
p=a.shift
l=[]
g=[]
a.map{|x|(x>p ?g:l).push x}
q[l]+[p]+q[g]
else
a
end}
$><<q[gets.scan /\w+/]*?,

I found that this implementation of gnome sort loops infinitely when the input items are not all unique, e.g. a b b.

Haskell, 141
import Data.List
m=minimum
s[]=[]
s l=m l:s(l\\[m l])
t[]=[]
t s=let(a,b)=span(/=',')s in a:t(drop 1 b)
main=interact$intercalate",".s.t.init

At least it’s… sort of efficient.

You can save 11 characters by using selection sort: m=minimum s[]=[] s l=m l:(s$l\\[m l]) (replace your lines 2–4 with these lines).

The init doesn't seem to be necessary as there is neither a trailing ,, nor a trailing newline. t s=let(a,b)=span(/=',')s in a:t(drop 1 b) can be shortened by using a pattern guard, using (>',') and dropping the space between 1 b: t s|(a,b)<-span(>',')s=a:t(drop 1b).

Using insertion with the insert function x#(y:r)|y<x=y:x#r;x#r=x:r is shorter. It can be used directly in t and as it does not use (\\) and intercalate"," can be replaced by tail.((',':)=<<), the import can be dropped. All together 101 bytes: Try it online!

vba, 165
Sub q()
c=","
s=InputBox("?")
Z=Split(s, c)
t=UBound(Z)
For i=1 To t-1
For j=i To t
If Z(i)>Z(j) Then a=Z(i):Z(i)=Z(j):Z(j)=a
Next
Next
Debug.Print Join(Z,c)
End Sub

I count 165 characters...

@Doorknob, fixed count... The greasemonkey script evidently gave me the wrong count as I was typing in the code.

You can get rid of a space in that Split.

Using c="," and calling c twice actually adds to the byte count in this case, contributing 7 bytes to the byte count, where as just using "," twice would contribute 6 bytes. You can lower your byte code by taking input directly from the sub call (sub q(s)) and assuming s is of type variant\string. You can lose one more byte by changing For i=1 to to for i=1To. you can lose 5 bytes by changing Debug.Print Join... to Debug.?Join...

PHP 83 bytes
<?for($x=fgetcsv(STDIN);$x;)${$x[0]>min($x)?x:a}[]=array_shift($x)?><?=join(~Ó,$a);

An O(n3) implementation of a selection sort. The Ó is character 211; a bit-inverted comma.
Sample usage:
$ more in.dat
code,sorting,hello,golf

$ php list-sort.php < in.dat
code,golf,hello,sorting

Scala, 122 bytes
As a one-liner (88 bytes):
.permutations.filter(_.sliding(2).map(w=>w(0)<w.last).fold(true)((a,b)=>a&&b)).toSeq(0)

(it will sort a list by just doing list.permutations.fil... )
As a program (122 bytes):
println(readLine.split(",").toSeq.permutations.filter(_.sliding(2).map(w=>w(0)<w.last).fold(true)((a,b)=>a&&b)).toSeq(0))

A longer version if you want it to read from stdin.
This iterate over all the permutations of the given list until it stumble on a sorted one. It's not fast as it takes about 12 seconds to sort a 10 elements list and well over a minute for a 11 elements one.
[Edit] items need to be unique or < can be replaced by <=.
Also, sorry for necro.

Python 3 (80 chars)
l=input().split(',')
m=[]
while l:m+=[l.pop(l.index(min(l)))]
print(','.join(m))

Here is a variation of the while-statement that is of equal length:
while l:x=min(l);m+=[x];l.remove(x)

Mathematica 66 56
Row[#[[Ordering@#]]&[InputString[]~StringSplit~","],","]

Some other solutions without the build-in symbol Ordering:
Bogosort: 84 74
NestWhile[RandomSample,InputString[]~StringSplit~",",!OrderedQ@#&]~Row~","

Bubble Sort: 93 83
Row[InputString[]~StringSplit~","//.{x___,i_,j_,y___}/;j~Order~i==1:>{x,j,i,y},","]

Another solution as inefficient as bogosort: 82 72
#~Row~","&/@Permutations[InputString[]~StringSplit~","]~Select~OrderedQ;

Python 3.5+, 73 bytes
This takes inspiration from Steven Rumbalski's answer but uses list comprehension instead of a while loop; the number of iterations comes from the copied list l which is the reason this requires additional unpacking generalizations and Python 3.5
l=input().split(',');print(*[l.pop(l.index(min(l)))for _ in[*l]],sep=',')

javascript 128
a=prompt().split(',');b=[];for(i in a){b.push(a[i]);k=0;for(j in b){j=k;b[j]>a[i]?[c=b[j],b.splice(j,1),b.push(c)]:k++}}alert(b)

DEMO fiddle.
i am looking for a way to eliminate b.

Remove the [] around the part after the ? to save 2 chars

@Doorknob i have tried it before i get SyntaxError: missing : in conditional expression because ?:; (the shorthand if/else) is only supposed to take two pecies of code to execute (i.e. true?b++:b--;) using [,] is a hack, im still not sure why it works, i think its understood as a empty array declaration, like placing a random string or number as a stand-alone command. but you can still feel free to upvote.

Hmm, I suppose  I was mistaken. The comma operator can execute multiple pieces of code at once. Using parenthesis works, so I suppose the ?: operator's precedence is lower than ,

No, did you try? Parenthesis still work...

@Doorknob your right, however i tried {,} and it didnt work - i get SyntaxError: missing : after property id. as for precedence parentheses is always first. i still would like a upvote....

That's because {} is for object literals... yes, the whole point of parenthesis is to gain higher precedence.

R
 Bubble Sort: 122 118 characters
a=scan(,"",sep=",");h=T;while(h){h=F;for(i in 1:(length(a)-1)){j=i+1;if(a[i]>a[j]){a[j:i]=a[i:j];h=T}}};cat(a,sep=",")

 Bogosort: 100 characters
a=scan(,"",sep=",");while(any(apply(embed(a,2),1,function(x)x[1]<x[2]))){a=sample(a)};cat(a,sep=",")

Perl, 159
perl -F"," -lape "$m=$m<length()?length():$m for@F;$_{10**(2*$m)*sprintf'0.'.'%02d'x$m,map-96+ord,split//}=$_ for@F;$_=join',',map$_{$_+0},grep exists$_{$_+0},'0'.1..'0'.10**100"

This never stood a chance to win, but decided to share it because I liked the logic even if it's a mess :) The idea behind it, is to convert each word into an integer (done using the ord function), we save the number as a key in a hash and the string as a value, and then we iterate increasingly through all integers (1..10**100 in this case) and that way we get our strings sorted.
WARNING: Don't run this code on your computer, since it loops through trillions+ of integers. If you want to test it, you can lower the upper range limit and input non-lengthy strings. If for any reason this is against the rules, please let me know and I'll delete the entry!

JS: 107 chars - Bubble Sort
a=prompt().split(/,/);for(i=a.length;i--;)for(j=0;j<i;)a[j]>a[j+1]?[b=a[j],a[j]=a[++j],a[j]=b]:j++;alert(a)

I looked at @tryingToGetProgrammingStraight's answer and tried to improve it, but ended up implementing it slightly differently.

Java, 134 bytes
A method that implements Gnome Sort.
void s(String[]a){int m=a.length-1,i=0;while(i<m){while(i>=0&&a[i].compareTo(a[i+1])>0){String t=a[i];a[i]=a[i+1];a[i+1]=t;i--;}i++;}}

Swift, 101 bytes
func s(a:[String])->[String]{return a.count<2 ? a:(s(a.filter{$0<a[0]})+[a[0]]+s(a.filter{$0>a[0]}))}

Ungolfed:
//quicksort
func sort(a:[String]) -> [String]
{
    //return the array if its length is less than or equal to 1
    if a.count <= 1
    {
        return a
    }
    //choose the first element as pivot
    let pivot = a[0]
    //retrieve all elements less than the pivot
    let left = a.filter{ $0 < pivot }
    //retrieve all elements greater than the pivot
    let right = a.filter{ $0 > pivot }
    //sort the left partition, append a new array containing the pivot,
    //append the sorted right partition
    return sort(left) + Array<String>(arrayLiteral: pivot) + sort(right)
}

This does not take and return the strings in the given comma-separated format.

, 24 chars / 30 bytes (noncompetitive)
ï⇔Ĕ⍪;↻ïꝈ)ΞÿѨŗ ï,⇀$≔МƵï;Ξ

Try it here (Firefox only).
Using selection sort!
Explanation
ï⇔Ĕ⍪;↻ïꝈ)ΞÿѨŗ ï,⇀$≔МƵï;Ξ // implicit: ï=input, Ξ=[]
ï⇔Ĕ⍪;                    // split ï along commas and set it to ï
     ↻ïꝈ)                // while ï's length > 0
         Ξÿ              // push to Ξ:
           Ѩŗ ï,⇀$≔МƵï;  // removed minimum item(s) from ï using builtin
                       Ξ // get sorted array

Basically recursively removes and pushes the minimum from the input to another array.

Ceylon (Bogosort), 119
String s(String i)=>",".join([*i.split(','.equals)].permutations.select((p)=>!any{for([x,y]in p.paired)y<x})[0]else[]);

Try it online!
I found the permutations method and thus ended up with Bogosort (a non-random variant).
Formatted and commented:
// a function `s` mapping a String `i` to a String
String s(String i) =>
    // the end result is created by joining the iterable in (...).
    ",".join(
        // take the input, split it on commas, make the result a sequence.
        [*
            i.split(','.equals)   // → {String+}
           ]                      // → [String+]
        // get the iterable of all permutations of this sequence.
        // Yes, this is an iterable of O(n!) sequences (though likely
        // lazily computed, we don't need all in memory at once).
        .permutations              // → {[String+]*}
        // filter this iterable for ordered sequences.
        // Using select instead of filter makes this
        // eager instead of lazy, so we are actually iterating
        // through all n! sequences, and storing the ordered
        // ones. (All of those are equal.)
        .select(
            // this is our function to check whether this sequence
            // is ordered in ascending order.
            (p)=>
               // return if none of the following iterable of booleans is true.
                !any {
                   // This is a for-comprehension. Inside an named argument list
                   // (what we have here, although there is no name) for a
                   // function which wants an iterable, this becomes an iterable,
                   // lazily built from the existing iterable p.paired,
                   // which is just an iterable with all pairs of subsequent
                   // elements.
                      for([x,y] in p.paired)
                        // for each such pair, we evaluate this expression, which
                        // is true when the sequence is not ordered correctly.
                           y < x         // → Boolean
                        // → {Boolean*}
                    }  //   → Boolean
                 //  → Boolean([String+])
               ) // → [[String+]*]
         // we now have a sequence of (correctly sorted) sequences.
         // just take the first one.
         // If we had used `.filter` before, this would have to be `.first`.
               [0]    // → [String+]|Null
         // in case this is null, which can only happen if the original array was
         // empty, so there were no permutations, just use the empty sequence
         //  again. (Actually, split never returns an empty array, so this can't
         //  happen, but the type checker can't know that.)
               else []    // → [String*]
    // so that is what we pass to the join method.
        )   // → String
    ;

Without the formatting and parsing it becomes just 90 bytes:
String[]s(String[]i)=>i.permutations.select((p)=>!any{for([x,y]in p.paired)y<x})[0]else[];

Try it online!

Perl 5, 77 bytes
map{$F[$_]gt$F[$_+1]&&(@F[$_,$_+1]=@F[$_+1,$_])for 0..@F-2}@F;$_=join',',"@F"

Try it online!
Simple bubble sort.

ruby -plaF, , 70 bytes
o=[]
$F.map{|s|i=o;s.bytes{|b|i=i[b]=[*i[b]]};i[0]=s<<?,}
$_=o*''
chop

O(n), if you pretend that resizing and compacting an array is free (it is very not free).
We create a deeply and unevenly nested array o by putting a string with bytes b1,b2...bn into the array at position o[b1][b2]...[bn]. The result looks like [,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,["a,",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, [,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ["abc,"], ["abd,"], ["abe,"]], ["ac,"], ["ad,"]],, ["c,"]]
Then we flatten and output it.

Reusing my own answer on Sort an Integer List

Tcl, 211 bytes
set L [split [gets stdin] ,]
set i 0
time {incr j;set x 0;while \$x<$i {if \"[lindex $L $i]"<"[lindex $L $x]" {set L [lreplace [linsert $L $x [lindex $L $i]] $j $j]};incr x};incr i} [llength $L]
puts [join $L ,]

Try it online!