Character counts in source code
///, 12 bytes
4
4 4
4
A big thank you goes to @user23013, who suggested this improvement over my CJam code, outgolfing his own, highest-scoring answer in the process.
The characters are sorted by appearance. This code works in any language that just prints its own source code under the given circumstances (PHP, ASP, etc.).
CJam, 20 bytes
''S5N'5S5N'NS5N'SS5N
This approach doesn't use any built-in character counting.
Try it online in the CJam interpreter.
How it works
''S5N e# Push a single quote, a space, the integer 5 and a linefeed.
'5S5N e# Push the character 5, a space, the integer 5 and a linefeed.
'NS5N e# Push the character N, a space, the integer 5 and a linefeed.
'SS5N e# Push the character S, a space, the integer 5 and a linefeed.
CJam, 20 bytes
{`"_~"+$e`{)S@N}%}_~
How it works
We first start off with one of the standard quine in CJam
{`"_~"}_~
which pushes the first block on stack, copies it, and runs the copy, which makes it print the source code itself finally.
Then we add the logic to compute the character count from the source code:
{`"_~"+ e# At this point, we have the full source code with us
$e` e# Sort to get similar characters together and run RLE to
e# get count of each character as [count char] array
{ }% e# Run each array element through this loop
)S@N e# Pop the character, put a space, rotate the count after
e# space and then finally put a newline after the trio
}_~ e# Second half of the standard quine explained above
Try it online here
CJam, 14 bytes
{S2N`/}`{S2N}/
Try it here.
Output is in the order they firstly appears:
{ 2
S 2
2 2
N 2
` 2
/ 2
} 2
It simply appends <SP>2<NL>
to each character in {S2N`/}
.