[Question]
  [
Write a program that takes no input and prints `Hello, World!` to stdout or your language's closest alternative. The catch is that each line in your program must only contain [printable ASCII characters](http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters) and it must be in lexicographical order, a.k.a. sorted.
Here are all 95 printable ASCII characters in order:
```
 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
```
So, for example, the line `!!A0~` would be invalid because the `A` and `0` are out of order. The line `!!0A~` would be valid.
Each line in your program may be any length and there may be any number of lines. Empty lines are considered sorted. Each of the newlines in your program must be the same (no mixing `\n` and `\r\n`). Tabs and other non-printable ASCII characters are forbidden.
**Due to [popular demand](https://codegolf.stackexchange.com/questions/48207/shortest-sorted-hello-world/48211#comment113279_48207), the win condition has been switched around:**  
The submission with the fewest *lines* wins. Tiebreaker goes to the shortest program (newlines count as single characters).
Only `Hello, World!` and an optional trailing newline should be output. Note that [HQ9+](http://esolangs.org/wiki/HQ9+) is invalid since it outputs `hello, world`. I may forbid languages similar to HQ9+ that have one character "Hello, World!" commands due to their triviality.
Hint:
> 
>  This is definitely possible in [Unary](http://esolangs.org/wiki/Unary) and [Lenguage](http://esolangs.org/wiki/Lenguage), though not very concisely.
> 
> 
> 
  
[Answer]
# [///](http://esolangs.org/wiki////), 7 lines, 22 bytes
```
/
//Hello
,
 Wor
l
d
!
```
A rare chance for /// to be competitive (well as long as no one starts with Unary and Lenguage...).
The code first encounters a `/`, and parses the 
```
/
//
```
as a substitution instruction which removes all newlines from the remainder of the program. Afterwards, the program merely reads
```
Hello, World!
```
which is printed verbatim as it doesn't contain any further slashes.
[Answer]
# [Headsecks](http://esolangs.org/wiki/Headsecks), 1 line, 366 bytes
```
                                                                        $(((((((((((((((((((((((((((((,000000044888<AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADIIIIIIIIIIIILPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPTXXXXXXXXXXXXXXXXXXXXXXXX\```diiiiiilqqqqqqqqtyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy|
```
Headsecks is a trivial Brainfuck substitution where the only thing that matters is the code point modulo 8. The equivalent Brainfuck is merely
```
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++++++..+++.-------------------------------------------------------------------.------------.+++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++.+++.------.--------.-------------------------------------------------------------------.
```
Luckily this naive approach *just* fits. There's some potential for golfing down bytes, but it might be hard.
Tested using [this Python interpreter](https://github.com/TieSoul/Multilang).
---
## Generating code
```
code = "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.+++++++++++++++++++++++++++++.+++++++..+++.-------------------------------------------------------------------.------------.+++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++++++.+++.------.--------.-------------------------------------------------------------------."
command_map = "+-<>.,[]"
last_point = 32
out = []
for char in code:
    curr_mod = command_map.index(char)
    last_mod = last_point % 8
    
    if curr_mod > last_mod:
        last_point += curr_mod - last_mod
    elif curr_mod < last_mod:
        last_point += (8 - last_mod) + curr_mod
    out.append(chr(last_point))
print("".join(out))
```
[Answer]
# JavaScript (~~67~~ ~~66~~ 62 lines, ~~227~~ 269 bytes)
(Note: only tested on Firefox 36 and Safari 8, contains minor ES6 features (the `Set` class))
```
Z
=
!""+
(0[[]]
+
(
!!""+Set
));c
=Z[~
-22]
$=Z[
3]
$$=Z[
15]
$$$=Z[
24]
$$$$=Z[
1]
$$$$$=Z[
0]
Set
[c
+
$$$+Z[
5]
+Z[
16]
+
$$$$$+
$$$$+Z[
2]
+c
+
$$$$$+
$$$+
$$$$]
(Z[
14]
+
$$+
$+
$$$$+
$$$$$+
"(\
'H\
"+
$+
$$+
$$+
$$$+
",\
 W\
"+
$$$+
$$$$+
$$+Z[
6]
+
"\
!')\
")
()
```
---
The code above basically does:
```
alert("Hello, World!")
```
Obviously `alert` is not sorted. So instead we need to generate the statement as a string, and "eval" it:
```
s = "alert('Hello, World!')";   // generate this using sorted code
eval(s)
```
How to generate the string? ES5 supports line continuation so that
```
"AL\
ERT" === "ALERT"
```
But the character code `\` appears *before* all lowercase letters, so we have to generate the lowercase letters using other methods.
We borrow some idea of [JSFuck](http://www.jsfuck.com/) here. The lowercase letters involved in the alert statements are:
```
t e r a o l d
```
all of these can be extracted from characters of standard objects, which may be expressed in terms of some sorted sequence:
```
t, e, r ← true      = !""
a, l    ← false     = !!""
o       ← function  = Set
d       ← undefined = 0[[]]
```
How do we evaluate the string? Surely we cannot use `eval(s)` as it is not sorted. Alternatively we could use `Function(s)()`, but we cannot use `Function` as it is not sorted either. However, `Function` is the constructor of all functions, which means `Set.constructor === Function`.
Adding the identifier `constructor` makes the list of lowercase letters become:
```
t e r a o l d c u n s
```
which fortunately could still be generated by `"truefalseundefinedfunction"`:
```
t, e, r, u ← true      = !""
a, l, s    ← false     = !!""
o, c, n    ← function  = Set
d          ← undefined = 0[[]]
```
---
After prettifying, the code above should read like:
```
// lines 1~8 defines our string containing all lowercase letters we want
Z = true + (undefined + (false + Set))
// Z = "trueundefinedfalsefunction Set() { [native code] }"
// lines 8~20 defines the variables `c`, `$` (e), `$$` (l), `$$$` (o), 
// `$$$$` (r), `$$$$$` (t)
// for the corresponding lowercase letters extracted from `Z`
// the rest calls:
Set["constructor"]("alert('Hello, World')")()
// lines 22~36 generates the "constructor" string
// lines 37~61 generates the "alert('Hello, World')" string
```
---
Update: Renamed `E`, `L`, `O`, `R`, `T` to various repetition of `$` to reduce 4 lines.
[Answer]
# [Insomnia](https://codegolf.stackexchange.com/questions/40073/making-future-posts-runnable-online-with-stack-snippets/41868#41868), 4 lines, 59 bytes
```
 FFFFGjnnnnooty
FLLddeejkopqyyyyy~~
(<ddjnoppppqrtu
<<Fddfj
```
This program is generated by optimizing for line count.
### 10 lines, 43 bytes
```
(u
pt
(dppty
p~
j
<Fptt{
(otz
?o
FLu
<?FFu~
```
This above program is generated by optimizing for byte count.
[Answer]
# Cygwin bash, 16 lines, 60 bytes
This only works due to the case-insensitive file name on Windows, and the fact that Cygwin look up the utilities case-insensitively even if you don't set it to recognize path case-insensitively.
```
A\
=Hello
A\
+=\
",
"Wor
A\
+=l
A\
+=d
A\
+=\
!
E\
CHO\
 $A
```
Take note of that `ECHO` at the end.
[Answer]
# [><>](http://esolangs.org/wiki/Fish), 6 lines, 111 bytes
```
  """""""/;;Hello
        &\o
      &++\oooo~~
"++++++++\bbbdlr
    +++++\ccccccccfooo}
    $++66\cfffffooooopr
```
I'm having trouble golfing out an extra line, but in any case I'm happy to have beaten the 7-line method.
## Explanation
><> is a stack-based 2D language where instructions are single chars and program flow can be up, down, left or right. The `"` instruction toggles string parsing, pushing chars until a closing `"` is met, but because of the nature of ><> there's no such thing as "multi-line string parsing" like with CJam's strings or Python's triple quoted strings. This turned out to be a major problem because starting and ending a line with a `"` and having other chars in between (e.g. `"some chars"`) is not allowed!
Note that `/` and `\` reflect program flow, so we actually execute the first line then all of the lines in reverse order, and most lines are actually executed backwards!
```
[Line 1]
""""""              Three empty strings, push nothing
"/;;Hello  "        Push "/;;Hello  ". Note the wrapping - ><> is toroidal!
""""""              Three empty strings, push nothing
[Line 6]
66++$               Turn the top " " into "," by adding 12, then swap top two
rp                  Reverse stack and pop top 3
ooooo               Print "Hello", stack is now " ,"
fffffc              Push some 15s and a 12
[Line 5]
+++++               Sum the 15s and 12 to give 87, or "W"
}ooo                Move "W" to the back and output ", W"
fcccccccc           Push a 15 and some 12s
[Line 4]
++++++++            Sum the 15 and 12s to give 111, or "o"
"rldbbb\++++++++"   Push chars to stack
r                   Reverse stack
ld                  Push length of stack and 13, not used
bbb                 Push three 11s
[Line 3]
++&                 Sum the 11s to give 33, or "!" and put in register
~~                  Pop top two
oooo                Print "orld"
[Line 2]
&                   Put "!" from register to stack
o                   Print "!"
[Line 1]
;                   Terminate
```
---
On a side note, here's an amusing attempt at a ><> least bytes (23 lines, 47 bytes):
```
v
"
!
d
l
r
o
W
,
o
l
l
e
H
"
/<
l
?
!
;
o
\^
```
[Answer]
# CJam, ~~5~~ 4 lines, 162 bytes
```
"Hello
")))))))))))))))))))))))))))))))))))68S\cel
"Wor
")))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))@SX\c|
```
Same number of lines as Insomnia! (but a lot more bytes)
[Try it online](http://cjam.aditsu.net/#code=%22Hello%0A%22%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%2968S%5Ccel%0A%22Wor%0A%22%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%40SX%5Cc%7C).
## Explanation
```
"Hello\n"        Push "Hello" and a newline
)                Uncons the newline
)))...)))        Increment the newline into a ","
68S\             Push 68 and a space then swap, leaving 68 on top
c                Convert 68 into a char "D"
el               Lowercase "D" into "d"
"Wor\n"          Push "Wor" and a newline
)                Uncons the newline
)))...)))        Increment the newline into an "l"
@                Rotate top three elements, moving the "d" to the top
SX\              Push a space and 1 then swap, leaving the space on top
c                Convert the space (which is an array) into a char
|                Bitwise or the space (32) with 1 to give "!" (33)    
```
CJam automatically prints the stack afterwards.
Thanks to @Optimizer for reminding me that `Sc` works, because otherwise `SX|` fails (it does a setwise or instead, giving the array consisting of a space and 1).
[Answer]
# [><> (Fish)](http://esolangs.org/wiki/Fish), 5 lines, many bytes
The code is extremely long, when I say `[6535529689086686142930090 '+' signs]` and `[6535529689086686142930090 'd' characters]` in the first line of the code, I mean that there are literally `6535529689086686142930090` plus signs in a row!
(And for the following lines add the necessary prefix spaces.)
```
'[6535529689086686142930090 '+' signs]^`[6535529689086686142930090 'd' characters]
                                   **,/288
                                     -/:o
                             %**288:;?\
                                   (1:\
```
A shorter testable alternative which only prints `Hi`:
```
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++^`hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
                                                                                                                               **,/288
                                                                                                                                 -/:o
                                                                                                                         %**288:;?\
                                                                                                                               (1:\
```
Method:
* In the first line we create a huge number representing the string in base128.
* In the rest of the lines (going from bottom to top) we print the following character in every loop until the value of the integer reaches 0.
* The looping code is `:1(?;:882**%:o-288**,`.
(We can print arbitrary 2+ chars long string with this method.)
[Answer]
# PHP (7 / 17 lines, 36 / 59 bytes):
Due to the amount of invalid answer, I rewrote this answer.
The browser version? Gone.
But I have 2 solutions, both based on bitwise `xor` (`^`) of strings in PHP.
This is an extremely powerful solution! Sometimes, it allows to save plenty of bytes.
First, the shortest answer:
```
Echo
Hello
,AM^mm
,Wor
,OOO^
"#+n
";
```
I know, it looks awful, but it works!
The next one depends on newlines.
Yes, it uses newlines (`\n`/UNIX style is required)!
```
Echo
Bo
.ff
.e
.
"&*]ex
fn
"^
"\n
\n
\n
\n
\n
\n
\n
",B^c
;
```
The newlines on this one are required to work.
It isn't perfect, but works!
---
Both answers were based on [@MartinBüttner](https://codegolf.stackexchange.com/users/8478/martin-b%C3%BCttner)'s [solution](http://pastebin.com/MskntTra):
```
Echo
Hello
.
chr
(44
).
chr
(29
+3
).Wor
.l
.d
."!
";
```
---
A special thank to [@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳](https://codegolf.stackexchange.com/users/6638/n%CC%B4%CC%8B%CC%96h%CC%B7%CC%83%CD%89a%CC%B7%CC%BF%CC%ADh%CC%B8%CC%85%CC%A1t%CC%B5%CD%84%CC%A8d%CC%B7%CD%80%CC%B0h%CC%B7%CC%82%CC%B3), [@CJDennis](https://codegolf.stackexchange.com/users/29560/cj-dennis), [@MartinBüttner](https://codegolf.stackexchange.com/users/8478/martin-b%C3%BCttner) and [@skagedal](https://codegolf.stackexchange.com/users/38728/skagedal) for detecting all my mistakes and for their suggestions.
[Answer]
# Pyth, 7 lines, 23 bytes
```
-
"Hello
,
 Wor
l
d
!"b
```
Pretty simple, just use a multiline string and remove the newlines.
[Try it here.](https://pyth.herokuapp.com/?code=-%0A%22Hello%0A%2C%0A%20Wor%0Al%0Ad%0A!%22b&debug=0)
[Answer]
# Forth, 41 lines, 143 bytes
[Try it online.](http://ideone.com/rnp5FC)
I'm very proud of this. I whipped it out pretty quickly once I found I could do it, having Google searched for case-insensitive languages, and I already know Forth decently. It can almost definitely be shortened, both bytes and lines. Suggestions are appreciated. :D
This program essentially pushes the decimal value of each ASCII character, then prints each one. I attempted to optimize while I wrote it, hence it is less readable than I'd like.
```
33
99
1
+
DUp
8
+
2DUp
6
+
SWap
11
+
2OVer
SWap
8
9
*
EMit
1
+
EMit
DUp
DUp
EMit
EMit
3
+
EMit
29
3
2DUp
+
EMit
*
EMit
EMit
EMit
EMit
EMit
EMit
```
[Answer]
# Marbelous, 9 lines, 94 bytes
```
3333
    @ADD
    358C
++--29\\
++--3555DE
<<<<<<>>~~
+++++446666D
++++++++../\
      ++------
```
[Test it online here.](https://codegolf.stackexchange.com/a/40808) `Using spaces for blank cells` must be checked. 
**Visual representation of source:**
![Visual representation of above source](https://i.stack.imgur.com/mjmao.png)
**Explanation:** Each hexadecimal value in this program moves downward every "tick" (unless it is on `\\`, in which case it moves to the right). `++` will increment the value, `--` decrement, `~~` apply a bitwise not, etc. Values that fall of the bottom are printed as an ASCII character.
For example: The `33` in the top corner becomes `(((0x33 +1 +1) << 1) +1 +1 = 0x6C (l)`.
[Answer]
## Batch - 39 Lines (202 bytes)
I wanted to cut down on the size by enabling delayed expansion by running the code inside of a `cmd` call using the `/v on` switch, but could not get past all the carats.
```
@S^
ET^
LO^
C^
AL^
 EN^
ABL^
E^
DEL^
AY^
E^
DEX^
P^
ANS^
IO^
N
@S^
ET^
 0=Hello
@S^
ET^
 1=^
,^
 Wor
@S^
ET^
 2=l
@S^
ET^
 3=d
@E^
CHO^
 !^
0^
!!1^
!!2^
!!3^
!^^^
!
```
Without the newlines (and carats to escape newlines):
```
@SETLOCAL ENABLEDELAYEDEXPANSION
@SET 0=Hello
@SET 1=, Wor
@SET 2=l
@SET 3=d
@ECHO !0!!1!!2!!3!^^!
```
[Answer]
# Perl, 17 lines
```
$_
=
'pr
int
"Hello
,
 Wor
l
d
!"';s
!
!!g
;s
!.
*
!$&
!eex
```
[Answer]
# Rebol - 15 lines (51 bytes)
```
PRin
AJOin
[
'Hello
Sp 
+
12
Sp
'Wor
'l
'd
Sp
+
1
]
```
Words in Rebol are case-insensitive (eg. `PRINT`, `Print` and `print` would all call the same function).
The above code tidied up:
```
prin ajoin [
    'Hello  sp + 12  sp  'Wor  'l  'd  sp + 1
]
```
NB. `sp` returns the space [char!](http://www.rebol.com/r3/docs/datatypes/char.html)
[Answer]
# [Unary](http://esolangs.org/wiki/Unary), 1 line, lots of bytes
Every character in this program is `0`. The source is too long to put in here, but it consists of a string of this many zeros:
```
327380789025192647555922325233404088310881092761595127419003295178342329930050528932118548
```
This is the decimal representation for this binary number:
```
0b1010010010010010010010010110000010010010010110000010010000010010010000010010010000010001001001001011111000010000010000011110001111001011111000000100000011011011100010010010010010010010100100010010010100000000100001011100001100010010010100011011011011011011100011011011011011011011011100000000010100
```
Which was created from this BrainF\*\*\* program:
```
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>-[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.
```
See how I generated it: <http://ideone.com/lMT40p>
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal), 9 lines, 25 bytes
```
`
Hello
,
 Wor
l
d
!`
\
-
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=&code=%60%0AHello%0A%2C%0A%20Wor%0Al%0Ad%0A!%60%0A%5C%0A-&inputs=&header=&footer=)
```
`        #
Hello    |
,        |
 Wor     | Push 'Hello\n,\n Wor\nl\nd\n!'
l        |
d        |
!`       #
     \   # Push '\n'
      -  # Remove all '\n' from 'Hello\n,\n Wor\nl\nd\n!'
         # Implicit output
```
[Answer]
# Ruby, 19 lines, 95 bytes
```
$;=
$>
$;<<
:Hello
$;<<
44::chr
$.=
33::
-1
$;<<
$.::chr
$;<<
:Wor
$;<<
:l
$;<<
:d
$;<<
33::chr
```
Possibly the second-hardest code restriction for Ruby I've seen on this site, after the monstrosity [here](https://codegolf.stackexchange.com/questions/36639/the-symbols-vs-the-letters/36654#36654).
Edit for explanation: The only Ruby output method that's sorted is the `<<` method on STDOUT. Unfortunately, the constant for STDOUT is `$>`, and `>` is higher ASCII than most symbols, so it's not really possible to call a method on it. We need a multi-line assignment statement to get it into a more tractable variable name, `$;` (semicolon is still pretty high, but most variables of this form are either non-assignable, or can only be strings).
Symbols (`:Wor`, etc. ) are the easiest way to do a literal, and I don't see a way to strip newlines from a string, so I need multiple print statements. The space and punctuation can't go into a symbol literal, but luckily the `chr` method on numbers is legal, so I can get a character from its ASCII value. `::` is an alternate way of calling methods. Space is tricky because I can't write `32`, so I subtract 1 from 33 and assign it to a variable.
[Answer]
# Retina, 12 lines, 29 bytes (non-competing)
The language is newer than the challenge.
```
Hello
$
,
$
 Wor
$
l
$
d
$
!
```
[**Try it online**](https://tio.run/nexus/retina#@8/lkZqTk8@lwqUDxArh@UVAKgeIU4BY8f9/AA)
]