Sort characters by darkness Your program must take as input a line of characters, like this:

@+.0


And output the characters sorted by how dark they are, like this:

.+0@


Requirements:


You must use a monospaced font for darkness detection.
You must find out how many pixels each character takes up. You must actually draw the character and count pixels, i.e. you can't just hardcode pixel amounts.


As a more concrete rule: if you switched fonts, your program should still work. Furthermore, your program should be able to switch fonts by simply changing a variable or value or string in the code.

If you use antialiasing, you must count pixels as percentages of a fully black pixel. For example, an rgb(32, 32, 32) pixel will count as 1/8 of a full pixel. Disregard this rule if your characters are not antialiased.
After counting pixels, you must sort the characters by the amount of pixels, and output them in order.
This is code-golf, so the shortest code in bytes will win.
Bash + ImageMagick: 164 147 148 characters

while read -n1 c
do
o=`convert -size 20x15 xc: +antialias -font cour.ttf -draw "text 0,10 '$c'" xpm:-`
o=${o//[^ ]}
a[${#o}]+=$c
done
echo "${a[@]}"


Sample run:

bash-4.1$ echo -n '@+.0' | bash graysort.sh
. + 0 @


Separators are inserted between grayness groups. Characters with identical grayness level are not separated:

bash-4.1$ echo -n 'abcdefghijklmnopqrstuvwxyz' | bash graysort.sh
i cl jortz esv ax u df bgnpq y hk w m