[Question]
  [
**This question already has answers here**:
 
 
[Display number of occurrences for every character in an input string](/questions/19068/display-number-of-occurrences-for-every-character-in-an-input-string)
 (66 answers)
 
Closed 4 years ago.
Given a string of printable ASCII, output the frequency of each character in that string.
## The Challenge
* Input is given as a string of printable ASCII characters (decimal `[32-126]` inclusive).
* Output the frequency of each character, in ASCII order.
* The output must have a format similar to `[character][separator][count]`. Provided that there is a single, non-newline separating string between the character and its frequency, it is a valid output.
* Output can be a single string, multiple strings, list of 2-tuples, array of tuples, etc.
* Input and output can be given [using any convenient method.](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods)
* [Standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest in bytes wins.
## Sample I/O
```
abcd
//outputs
a: 1
b: 1
c: 1
d: 1
```
```
Over 9001!
//outputs
  [ 1
! [ 1
0 [ 2
1 [ 1
9 [ 1
O [ 1
e [ 1
r [ 1
v [ 1
```
```
--<-<<+[+[<+>--->->->-<<<]>]<<--.<++++++.<<-..<<.<+.>>.>>.<<<.+++.>>.>>-.<<<+.
//outputs (as 2-tuples)
(+,14),(-,13),(.,13),(<,21),(>,13),([,2),(],2)
```
```
Su3OH39IguWH
//outputs (as 2d array)
[[3,2],[9,1],[H,2],[I,1],[O,1],[S,1],[W,1],[g,1],[u,2]]
```
  
[Answer]
# [Python 3](https://docs.python.org/3/), ~~50, 43~~, 41 bytes
```
lambda s:{c:s.count(c)for c in sorted(s)}
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUaHYqjrZqlgvOb80r0QjWTMtv0ghWSEzT6E4v6gkNUWjWLP2f0FRJlAuTUMpMSk5JVFJU/M/AA "Python 3 – Try It Online")
[Answer]
# [Ohm v2](https://github.com/nickbclifford/Ohm), 2 bytes
```
SÖ
```
[Try it online!](https://tio.run/##HYqxDcBADAJ3@daC4mvkJVK@vv8myjZZKIM5tgEhneA594y4vjdiAIJky5bMAXhb0vYtAZS1mMCsZLpX8sMamlBoHD8 "Ohm v2 – Try It Online")
```
      implicit input
S     sort string
 Ö    run-length encoding
      implicitly print
```
[Answer]
# [Python 3](https://docs.python.org/3/), 41 bytes
```
lambda s:sorted({*zip(s,map(s.count,s))})
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUaHYqji/qCQ1RaNaqyqzQKNYJzcRSOol55fmlegUa2rWav4vKMrMK9FI01BKTEpOSVTS1PwPAA)
[Answer]
# [J](http://jsoftware.com/), 13 bytes
```
({.;#)/.~@/:~
```
[Try it online!](https://tio.run/##PcqxCsJADAbgvU8RdIgl5q/zmYaC4OTkWjpotYiLDyD01c/cDSb5Ax/JO2/AC/WJmPZ0oBRR0Ol6OefdF8dt22EdurTmtmme8@tDC/HtPj/4L1VTMxllNHFV9dpmNvlkpgqTWgggVhjuZeIH5VClhQLOPw "J – Try It Online")
* `@/:~` sort the input and...
* `/.~` partition it into groups of like items. Apply the following to each group...
* `({.;#)` take the first element `{.` and link it `;` to the number of items in the group `#`
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 2 bytes
```
ọo
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFRu/6htw6Ompoe7Omsfbp3w/@Hu3vz//6OVEpOSU5R0lPzLUosULA0MDBWBHF1dG10bG@1o7WgbbTtdXV07MLSxsYm1i7Wx0dXVs9EGAz0gRw9IAPl6dnYgBFSjB5IA83RBXG09oIHBpcb@HsaWnuml4R5KsQA "Brachylog – Try It Online")
```
ọ     Occurrences,
 o    sorted.
```
It's essentially the same as using an RLE builtin with the sorting requirement, but if the output could be in any order it would just be `ọ`.
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 5 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
Anonymous tacit prefix function, returning a two-column table, which by default prints with space as separator between character and count, and line break after each entry.
```
,∘≢⌸∧
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/X@dRx4xHnYse9ex41LH8f9qjtgmPevse9U319H/U1XxovfGjtolAXnCQM5AM8fAM/p@moJ6YlJyizqWrq8sF5PiXpRYpWBoYGCrChXR1bXRtbLSjtaNttO2AYnZgaGNjE2sXa2Ojq6tnow0GekCOHpAA8vXs7EAIqEYPJAHm6YK42npwY4NLjf09jC0900vDPdQB "APL (Dyalog Extended) – Try It Online")
`,` character followed
`∘` by
`≢` its tally
`⌸` for each unique character
`∧` in ascending order
[Answer]
# [Haskell](https://www.haskell.org/), ~~52~~ 49 bytes
*-3 bytes thanks to cole!*
```
import Data.List
map((,).nub<*>length).group.sort
```
[Try it online!](https://tio.run/##DcqxCoAgEADQ3a@4oqEipMYgmxqDvuECK0lNzrPft978Loy3tjZn48JDDAsyytVEFodyGOq6a6RP@9TOVvuTr0ae9KQg45@zcGg8KAhkPEMFB5TbqwnGvh@KMn8 "Haskell – Try It Online")
I know this is too long (especially that import), but I'm new at Haskell golfing and hoping to get better! Outputs as a list of tuples of `(character, count)` (note the `character` is `String`, not a `Char`).
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 15 bytes
```
*.comb.Bag.sort
```
[Try it online!](https://tio.run/##HYoxC4MwFIT3/Ip0kdbwHhahIL5m6GQnhw4dxCHaKAVTJdaCvz5NcnccfNwt2k4XZ3aeDPzqUuxn0@FNjbjO9utKNr0/ekWjlmOKyYCr2k9Odf2L1T9teZFl5wMDICASjWhISACQ0UTUypYIAElEoQf05RmlDPEfDEMkCCiQPba8rvLiPm7P6g8 "Perl 6 – Try It Online")
Anonymous code block that takes a string and returns a list of pairs, where the key is the character and the value is the number of occurrences.
### Explanation:
```
*.comb           # Decompose into characters
      .Bag       # Group into unordered bag of character => occurrences
          .sort  # Sort by character
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~8~~ 4 bytes
```
$e`p
```
[Try it online!](https://tio.run/##S85KzP1f9F8lNaHg///EpOSURAA "CJam – Try It Online")
-3 bytes thanks to Jonah, and -1 byte from rule interpretation. 
A perfect challenge for CJam. ~~I had hoped that the RLE encode operator would output `[char, count]`, but the order was reversed. Otherwise it would have been a 5-byter.~~ After Jonah's comment, I switched the order of the output. ~~I'm not sure if the first read should be counted, since the standard rules permit input to be on the stack at the start of the program. If that's the case, this answer is one byte shorter.~~ From [this meta discussion](https://codegolf.meta.stackexchange.com/a/8493/79994), I concluded that the read could be placed in the header. Otherwise I could modify the script to be a function without changing the byte count. 
## Explanation
```
 $       sort string
  e`     RLE-encode (transforms "aabc" to [[2, "a"], [1, "b"], [1, "c"]]
    p    print
```
**Open question**: would something [like this](https://tio.run/##S85KzP1fVP1fJTXhf21dwf/EpOSURAA) be allowed if transforming the answer to a function, or should the brackets be included in the byte count? 
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 3 bytes
```
r8S
```
[Try it online!](https://tio.run/##K6gsyfj/v8gi@P9/Jf@y1CIFSwMDQ0UlAA "Pyth – Try It Online")
Simply run-length encodes (`r8`) the sorted (`S`) input. Output is a list of tuples of `[frequency, character]`.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~6~~ 3 bytes
```
ṢŒr
```
[Try it online!](https://tio.run/##y0rNyan8///hzkVHJxX9P9zu/v9/cKmxv4expWd6abgHAA "Jelly – Try It Online")
A monadic link taking the string as its argument. Returns a list of lists, each one containing the character and count. The footer formats this as a grid.
[Answer]
# [Bash](https://www.gnu.org/software/bash/), ~~27~~ ~~22~~ 20 bytes
```
fold -1|sort|uniq -c
```
[Try it online!](https://tio.run/##Lc3BCsIwDAbg@54ityrlD3j/yYuMHbbOMkEsOj1Zn722ZUlI@Eggy7xvJcrpLN8S030VXPKeXu/8edyeglB@w3ANWxI3L2F1kiUedscECNKPfqQ3ANaT5GQTCSh9D63Q2qrVrFW90bboQqPX/qH8AQ "Bash – Try It Online")
*-5 bytes thanks to Neil*
*-2 bytes thanks to Digital Trauma*
[Answer]
# [PHP](https://php.net/), 57 bytes
```
foreach(count_chars($argn,1)as$a=>$b)echo chr($a)," $b
";
```
[Try it online!](https://tio.run/##NY7BasMwDIbvfgotGNLgyLT0VKK6p0IGgxR22CELxfGy@pQEO9ll7Nkzx9kkIfRJ@oVGOy50Ge3IGJ86P3k4Q80AUt2ajzRfq@qrc3Da7w9PGyMSEola1CQUIqroRNSohghRkogmA8iQAkul1gg7ch1EwhWF3G6@zseqPJ6eH/NbmbKmYOxzcJ02dgd/b2kPXLtHDxl8B0Vn7LA1criVt/u1eimWf40Z5n66G6ud3207h0x7rs@Kt1lUGuvCJMsT4C1LiiU2k/c@KdjP8gs "PHP – Try It Online")
Input via `STDIN`, run with `php -F`:
```
$ echo Su3OH39IguWH|php -F cc.php
3 2
9 1
H 2
I 1
O 1
S 1
W 1
g 1
u 2
```
Fun fact: this challenge is basically the [**Example 1**](https://www.php.net/manual/en/function.count-chars.php#refsect1-function.count-chars-examples) on the PHP docs for [`count_chars()`](https://www.php.net/manual/en/function.count-chars.php#refsect1-function.count-chars-examples).
[Answer]
# T-SQL 2008 query, 130 bytes
```
DECLARE @ varchar(2000)='kabcdda'
SELECT w,sum(1)FROM(SELECT
substring(@,number+1,1)FROM
spt_values WHERE type='P'and
number<len(@))x(w)GROUP BY w
ORDER BY ascii(w)
```
**[Try it online](https://rextester.com/HBX36121)**
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 94 91 bytes
Thanks to Ourous and ceilingcat for their suggestions.
To get the non-newline separator, I'm making use of the fact that negative numbers get a "-" for free! :-)
```
f(char*s){char c[255]={},i=31;for(;*s;)c[*s++]--;for(;++i>0;)c[i]&&printf("%c%d ",i,c[i]);}
```
[Try it online!](https://tio.run/##LY3BboMwDEDv/QoPqVWIcUSHeqiS5tydethhB8SBpUAjbawK0B0Q354ldLaV@D1bsqHOGO9bZm6140M6xx9M@Xo4VKd5yeyp2Mv2xzHJB5makg@IFdFTIVqdR2ur3e7ubD@2LNma7RWSzGZRp3LxQcN3bXsWm9p1JoP1COcBHinMG4Dfm/1qGEf8V9Cy51TCfRoHliShWzZh0zXj5HrI5Wbxvv40V395NA6Oeb5/8USKlMISS4WaiPSaSqlKV0oRCYVriAAiPIGF1rHCjoiDlSgiCv8@FZdzcXzrpo/zHw "C (gcc) – Try It Online")
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~27~~ ~~22~~ ~~21~~ 19 bytes
```
$args[0]|sort|group
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/XyWxKL042iC2pji/qKQmvSi/tOD///8a0ckZiUXRsbHqwaXG/h7Glp7ppeEeGeqaAA "PowerShell – Try It Online")
Exactly what it says on the tin. Takes input `$args[0]` via splatting (manifests on TIO as a `[char[]]`), `sort`s it, then `group-object` it into a grouping.
*-8 bytes thanks to mazzy*
[Answer]
# JavaScript, 58 bytes
```
s=>[...s].sort().flatMap(c=>c>p?[p=[c,1]]:p[1]++&&[],p=[])
```
[Try it online!](https://tio.run/##jY3PCsIwDIfvPoV6kJaa4PCkZPWqgu7gwUPpoXZ/mIy1rFPw6We3BxCT8IMv@SBP8zbBdrXvoXV5MZTpEFKpEDFoDK7rGceyMf3FeGZTaaU/KJ8qu0603nuVaCFWK6XXcaf5YF0bXFNg4yp2vmVXDH1Xt1VdfljJluZhc7PknM9@e9m76Oa7zSZZ/CEDEBAJJRQJCQByaiLSUhMBIImpMALGiIxSjhMdHA8TwYgC/3h4e22z43Z3ql7346gPXw "JavaScript (Node.js) – Try It Online")
Thanks Shaggy, -1 byte.
---
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 18 bytes
```
O`.
(.)\1*
$1,$.&¶
```
[Try it online!](https://tio.run/##HYrBCYAwFEPvziGifhPoPfwVHEALevDgxYM4mwO4WG2bhMAjuY/nvPaQ0ryx6TmsYWzaMLXsvjclQJBssUXmALxaUvQoAZRVMQNzZaZ7Sf6wDJVQ0PgD "Retina – Try It Online")
I don't speak Retina. I just translated above JavaScript answer to Retina with some searching.
Thanks to Cows quack, -3 bytes.
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 34 bytes
```
KeySortBy[ToCharacterCode]@*Counts
```
[Try it online!](https://tio.run/##PYwxC8IwEIX3/ApNwcF4UXEqnKHYRXFQUXCIGWKNtkMbiKkg4m@vSQffHY/7uLtXa1@aWvuq0N192W3N@2idX73lyealdrrwxuX2ZlQ2zm3b@Gd3aCvjJSF7VzVe0gulKBIUcQBxz/5fzyxRo2n2IVRfixudELp7GTdIZ7P5MBIAAiKTTCITACD6QkQlFCIAR9aLB@DBAnMhYocbHhc9QUTGY@KxXezWi3TzaM9rSr6EqO4H "Wolfram Language (Mathematica) – Try It Online")
Returns an association.
---
```
SortBy[ToCharacterCode@@#&]@*Tally
```
[Try it online!](https://tio.run/##PYwxC8IwEIX3/ApNwcF4sdKpcIagi04qFhxihlijLVQLMRWK@Ntr08F3x@M@7u49jC/sw/gyN91t2R1r51etyup1YZzJvXXr@mqljCZaTjNTVW13aErrFSF7Vz69omdKUUQowgDiJv@PLxnpyVx@CDWX/EpnhO7e1o3SOF6MAwEgIDLFFDIBAGIoRNRCIwJwZIN4D7y3nrkQofsbHhYDQUDGQ@KxSXabJN3em9OGki8huvsB "Wolfram Language (Mathematica) – Try It Online")
Returns a list.
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 63 61 bytes
```
s=>s.OrderBy(c=>c).GroupBy(c=>c).Select(g=>(g.Key,g.Count()))
```
[Try it online!](https://tio.run/##PY7BCsIwDIbvPkXZqaNLXsA0BwUFPXjw4EE9SNeNgnbSdsKevnYTTELg4w9/fhPBRJd3ozcUU3C@b9rJP17OsOiEzlFzxFNobdhM0mg2Ne7DML7/dLZPa5LsNcsej3ZqetwOo0@yruu8Xq0@jyCSjUloUQEQEKmrupJiAOCliejOdyIAJLUUFsCyCiPzPOUGZ2EhmFFhVdwvwSUrf8HxMDgvq5uvGtHJ@WeJsM5f "C# (Visual C# Interactive Compiler) – Try It Online")
Thanks to Expired Data for pointing me towards the C# Interactive Compiler and for showing me the power of dynamics.
[Answer]
# [K4](https://kx.com/download/), 9 bytes
**Solution:**
```
#:'=x@<x:
```
**Example:**
```
q)k)#:'=x@<x:"Over 9001!"
 | 1
!| 1
0| 2
1| 1
9| 1
O| 1
e| 1
r| 1
v| 1
```
**Explanation:**
```
#:'=x@<x: / the solution
       x: / store input as x
      <   / indices to sort ascending
    x@    / apply (@) to x
   =      / group same values
#:'       / count (#:) each (')
```
[Answer]
# APL(NARS), 26 chars, 52 bytes
```
{m,¨+/¨{w=⍵}¨m←k[⍋k←∪w←⍵]}
```
test:
```
  ⎕fmt{m,¨+/¨{w=⍵}¨m←k[⍋k←∪w←⍵]}'is, this good or not?'
┌12─────────────────────────────────────────────────────────────────────────────────┐
│┌2───┐ ┌2───┐ ┌2───┐ ┌2───┐ ┌2───┐ ┌2───┐ ┌2───┐ ┌2───┐ ┌2───┐ ┌2───┐ ┌2───┐ ┌2───┐│
││   4│ │ , 1│ │ ? 1│ │ d 1│ │ g 1│ │ h 1│ │ i 2│ │ n 1│ │ o 4│ │ r 1│ │ s 2│ │ t 2││
│└+───┘ └+───┘ └+───┘ └+───┘ └+───┘ └+───┘ └+───┘ └+───┘ └+───┘ └+───┘ └+───┘ └+───┘2
└∊──────────────────────────────────────────────────────────────────────────────────┘
  {m,¨+/¨{w=⍵}¨m←k[⍋k←∪w←⍵]}
                     k←∪w←⍵     copy the argument in w, k is the argument that has unique elements
               m←k[⍋       ]    copy k order, in m, (so m is argument unique ordered)
         {w=⍵}¨m                see each element of m in w, so each element of m generate a len(w) bit list 
      +/¨                       sum each bit list above obtain the number of element of m in w
   m,¨                          make couples
```
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 128 114 bytes
```
->>,[[-[>>+<<-]>>]>+<+[-<<+]->>,]+[+>[<--.++<<+++++++[>++++++++<-]>++.[-]++++++[>>++++++++<<-]>>.[-].]<[>>+<<-]>>]
```
[Try it online!](https://tio.run/##TYxLCoAwDESv0v2YniAEXHqGkIUWhaJ2UfH81fpBZ/XgzcyQ@5imPcylkEijSioCZjIROwFKzLDqDApRJvI4C7ij8gDqBPBK9ppPXXdVeePffymdW@I8unYdcwx9cuu@xXAA "brainfuck – Try It Online")
How it works:
```
-                                          sets cell 0 to 255, which is used to move back to cell 2 later on
>>                                         moves to cell 2
,[                                         we load our first input and loop until there are no more characters to load
[-[>>+<<-]>>]                              keeps moving forward skipping every other cell until it has moved forward the ASCII value of the most recently loaded character  
>+<                                        adds one to the next cell for the purpose of later looking at to see how many of that character was entered
+[-<<+]->>                                 goes back to cell 2
,]                                         loads in next character and repeats process if there are remaining characters
+[+>[                                      checks IF the next cell has a value other than 0
<--.                                       then, if true, it prints the ASCII value of the previous cells contents
++<<+++++++[>++++++++<-]>++.               then print ":"
[-]++++++[>>++++++++<<-]>>.                then print the number value of the contents of the current cell
[-].]                                      then print a null character and leaves the if statement
<[>>+<<-]>>]                               continues the same process skipping every other cell, until it repeats 255 times
```
Thanks to Jo King, -14 bytes.
This is my second brainfuck program, first being hello world, and first time golfing, so please let me know what I can do to improve my program and answer!
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), 60 bytes
```
import StdEnv
$s=sort[(c,sum[1\\k<-s|k==c])\\c<-removeDup s]
```
[Try it online!](https://tio.run/##HcvBCsMgDAbg@57CQ6EbLsLu0VN3GOzWo3oQ60Zp1VLbwmDPPmebhB8@ktjRmZB97NbREW/6kHs/xXkh7dLdw3aqEk@F8myvafXyptSAkL4D51ZflLIIs/Nxc806kaRzu5jyy0lFZA2AgEgllUgFAIijEVELjQjAkB7FCliJYibEPuWG7YtDsJOyWueffY3mnTI8nrn5BON7m/4 "Clean – Try It Online")
Defines the function `$ :: [Char] -> [(Char, Int)]` giving the result as a list of 2-Tuples.  
Uses the element-wise behavior of `<` and thus `sort` on Tuples to ensure codepoint ordering.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 13 bytes
```
ＥΦγ№θι⁺⁺ι №θι
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM3sUDDLTOnJLVII11HwTm/FChWqKOQqampoxCQU1qsASYydRSUFJQ0URVoalqDTMlPL0rMzc3MS1cIKK2qykktVlADKktJVXDPz0nj@q9blgMA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
  γ             Printable ASCII
 Φ              Filtered where non-zero
   №            Count of
     ι          Current character in
    θ           Input string
Ｅ               Map over filtered characters
        ι       Current character
       ⁺        Plus a space
      ⁺         Plus
          №     Count of
            ι   Current character in
           θ    Input string
                Implicitly output on separate lines
```
[Answer]
# JavaScript, 57 bytes
Outputs a 2D-Array. Had to implement a quick & dirty fix for the sorting so I'll need to come back to try to golf that.
```
s=>[...s].map(o=x=>o[x]=-~o[x])&&Object.entries(o).sort()
```
[Try It Online!](https://tio.run/##RY6xjsIwDIb3PgW3oETBFicmTk5mmDrccEOuUkoJqBXEqCmo0716LylC2Jb9f7Jl/V39qGPTt7cBAh/9dNJT1MYiYqzwWt8E61EbtmOl4S8PuVyWh843A/ow9K2PgiVG7gchp4ZD5IvHC5@FLVx9aI5uVbjy4fvFdr3@/MgEQECkrLKkDACYOYmoMhURAJKaAxNgaonRmFzpBvNiJsioMH/8vm/K3Wa7P99/dq542k6mT2KULz1ix21wXwsnn@o3vFXW0z8)
[Answer]
# [Kotlin](https://kotlinlang.org), 75 bytes
```
fun String.c()=toCharArray().sorted().map{Pair(it,count{s->it==s})}.toSet()
```
[Try it online!](https://tio.run/##PY7BCsIwEETP9iuW0kMCth8gtiDiwZugx162TWyDupFkC0rIt8dWwZnLwAyPuVm@G0rpOhGc2Rkaql7Imu1@RLdzDt9CVt461moOD3yGExonDK97OxEHXzaG69pHGSu2Z81CflkPNCTQDX4DX8r2B28khCxbLUV1te6A/XgkpV9aQTBrXTbwnGd8J5FftGcoDJRQ6JZaKoJersWWcgkxy2JK6BV2/Yhdwr9Shx0Os73yatEH "Kotlin – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 7 bytes
```
¬ü ®âZl
```
[Test it online!](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=rPwgruJabA&input=IlN1M09IMzlJZ3VXSCIKLVI)
[Answer]
## Haskell, 46 bytes
```
f x=[(c,sum[1|d<-x,d==c])|c<-[' '..],elem c x]
```
[Try it online!](https://tio.run/##HYrRCsMgFEN/5VIG3dB7Ye/RHxEfirWsTMtYV/Ch/@60SQgckte0v2NKtS5UjLsHvR/ZPc8ZXPRsTPCPM4DdSKOI1zHFTIGKr3laNzL0@a7bj2600MAMBpRTDsoys70MwFsPMAvUJWkgrRqLtT3tI324iDsqGeof "Haskell – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-n`, 43 bytes
```
p$_.chars.uniq.sort.map{|c|[c,$_.count(c)]}
```
[Try it online!](https://tio.run/##HYpLDgIxDEMvwwIUkhNYuUhVoaEbZkFb@lkghqsT2tqWpSe79PvbLJ9uEh5bqdLj/pKaSpPnlj9HOFy4zjH12M7h4r9mzGCAHDmQMrMuA/DqAWYBLckAGTVYVGfGR@awiCeS/FJue4rVOP4B "Ruby – Try It Online")
[Answer]
# [sfk](http://stahlworks.com/dev/swiss-file-knife.html), ~~124~~ ~~87~~ 84 bytes
```
xed -i
+chars
+count -same -case
+xed "_?????*x*[white]?_[parts 6,3,1]_"
+sort -case
```
[Try it online!](https://tio.run/##JYvRCsMgDEXf/QrpY9MExmBPwX6IiEjnaBlbh7Gsf@/U3RsSDvdGHs9SznjXuClY1pCknv14Z40SXlHjEiQqaI3Bz03jOdrvuuXoZm8/IWXRt@k6XZwfFMie8v@nFERGZrBgGQwimm5mdsYxIxJDF1WguiqTMW1qh1rQCRsC/QA "sfk – Try It Online")
Gives output in the form `[character]x[count]` with `count` padded to 5 digits.
]