[Question]
  [
Letters of the words want fairness.
They decided to appear same number of times in a sentence equally.
Example:
```
Priorities
```
Will become:
```
Ppprrioooritttieeesss
```
Each letter appears 3 times, as the most common letter was `i`, appearing 3 times.
It does not matter where you put the repeated letters, as long as they are next to a similar letter.
I.e.:
`Pppriooorritttieeesss` is OK (the 'r' letter)
`Ppprioororitttieeesss` is not OK (the 'r' letter)
Another example:
```
invoice
```
Will become:
```
innvvooiccee
```
Another example:
```
Remittance Advice
```
Will become:
```
Rrremmmiitttaannncce Adddvvvice
```
Space, comma, question mark, quotation, etc. are not considered letters for this challenge. Only need to consider [a-zA-Z]. Just once space is enough, and the order of the letters should remain the same.
The capitalization of letters does not matter, upper and lower case are countes as the same letter. That is: `Pip` has 2 'P's and 1 'I', so it will become `Piip`.
It is case insensitive letters can be in any form, `Piip=piip=piiP=PiiP`
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'")
  
[Answer]
# [R](https://www.r-project.org/), 106 bytes
```
function(s){for(A in L<-LETTERS)s=sub(A,strrep(A,max(x<-+s-+Map(gsub,L,'',s,T))-x[A]--1),s,T);s}
"+"=nchar
```
[Try it online!](https://tio.run/##PcmxDoMgFIXh3acwLEKEoXN1YHCjibFuTQdKob2DYLhoTJo@OzVt0u1854/Ztdkt3iQIniJ7uRCpLMGXqhGqG8duODNscblRyTHFaOd9THqjWyNqFPVJz/SxZ654VXHkI2Niu8irEAf25RHfBalJ681Tx@wo6SOECAksElbsBr8GMPaHwU6QkvbGlvK@/u8eZsLyBw "R – Try It Online")
Base R approach :
* stealing some ideas from [@J.Doe R+stringr approach](https://codegolf.stackexchange.com/a/173341/41725), I saved 26 bytes !
* another 5 bytes saved using @J.Doe suggestion to abuse R `+` operator
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 16 bytes
```
lDáÙSÐ¹ls¢Zα>×.;
```
[Try it online!](https://tio.run/##ATIAzf9vc2FiaWX//2xEw6HDmVPDkMK5bHPColrOsT7Dly47//9SZW1pdHRhbmNlIEFkdmljZQ "05AB1E – Try It Online")
**Explanation**
```
l                  # convert input to lowercase
 D                 # duplicate
  á                # keep only letters
   Ù               # remove duplicates
    S              # split to list of chars
     Ð             # triplicate
      ¹ls¢         # count the occurrences of each letter in lowercase input
          Zα       # absolute valuue with max occurrence
            >      # increment
             ×     # repeat each unique char that many times
              .;   # replace the first occurrence of the char in lowercase input with this
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 82 bytes
*-3 bytes thanks to nwellnhof*
```
->\a{a.=lc.=subst($_,$_ x a.comb(/<:L>/).Bag.values.max+1-a.comb($_))for 'a'..'z'}
```
[Try it online!](https://tio.run/##LY7NC4IwGMbP@le8jNGUdNKlQ6ZQ5w7RORhva8bALzYVS/zbzUWHh@fjd3laZcr9Ur1hU0AGS5zfcUKelZJntn/YLqAiogJGQC6b6hEkx8MlT0J@xhcfsOyV5RWO213851SEYdEYYMg4Zx82L6nvOmmNbozutLIkAqLrodFSuXhTle46rKWC03P4jeSqWwKT762/KK6/qJNIfa8IKIarW3TEn5cv "Perl 6 – Try It Online")
Takes a mutable string and modifies it in place.
### Explanation:
```
->\a{        # Anonymous code block that takes a mutable string            }
 a.=lc;  # Lowercase
                                                               for 'a'..'z'  # For each letter
 .=subst(                                                    )  # Substitute
          $_,   #The first occurrence of the letter with
             $_ x  #The letter repeated
                  a.comb(/<:L>/).Bag.values.max    # The count of the most common letter
                                                 +1  # Plus 1
                                                   -a.comb($_)  # Minus the count of that letter already in the string
```
[Answer]
# JavaScript (ES6), 112 bytes
```
s=>(m=g=F=>s.replace(/[a-z]/gi,c=>F(c.toLowerCase())))(c=>g[c]=c+c.repeat(m-g[c]),g(c=>m=(n=g[c]=-~g[c])<m?m:n))
```
[Try it online!](https://tio.run/##bYu9CsIwFEZ3n8LNG@zPLt6KCJ0cxLV0CLe3IdIkJQkVHHz12NZN/MZzzveQkwzk9Rhz6zpOPaaAFRhUWGMVCs/jIImhbGT@akulM8KqBiqiu7on@4sMDGIezFw11CLtaXmxjGDyhYhMLdIgWFyL/L3iozmZgxUikbPBDVwMTkEPu5vXzuuoOeyE2PxIbSenif@YOxsdo7TE23M3fZv0AQ "JavaScript (Node.js) – Try It Online")
### Commented
```
s => (                       // s = input string
  m =                        // m = max. number of occurrences of the same letter
  g = F =>                   // g = helper function taking a callback function F
    s.replace(               //     (also used to store the # of occurrences of each letter)
      /[a-z]/gi,             //   for each letter c in s:
      c => F(                //     invoke F():
        c.toLowerCase()      //       with c.toLowerCase()
      )                      //     end of call to F()
    )                        //   end of replace()
)(c =>                       // invoke g() (second pass):
  g[c] =                     //   update g[c] to a non-numeric value
    c +                      //   append c once, unconditionally
    c.repeat(m - g[c]),      //   and append c as many times as required to reach m
                             //   (any subsequent iteration with the same letter will
                             //   lead to c.repeat(m - g[c]) --> c.repeat(NaN) --> '')
  g(c =>                     //   invoke g() (first pass):
    m = (n = g[c] = -~g[c])  //     increment g[c], save the result in n
      < m ? m : n            //     and update m to max(m, n)
  )                          //   end of first pass
)                            // end of second pass
```
[Answer]
# [J](http://jsoftware.com/), ~~33~~ ~~56~~ 46 bytes
```
t=:~:tolower
(#~1+t*~:(*>./-])t*1#.e.)@toupper
```
[Try it online!](https://tio.run/##HYyxCsIwFEX3fsXDDmmjRrtGUqKbi4i7g8QXjGhTkmcdpP31GnLgwoUD5zmfDgIWApgFJRmsYJSwhbSZlJwk@Zf/YiisklU5NUvik6x4Kzbra028KQWKWpP/9D2GnKqLmELAzsH54MhhZDt27AbvDKZ3wbcj4rfOIPwy@/uQ1JhhBZqH11a3EOc/ "J – Try It Online")
Couldn't find a way to avoid using `~:tolower` twice.
### How it works
```
t=:~:tolower    Auxiliary function: isupper
     tolower    Is lowercase version of itself...
   ~:           different from itself?
(#~1+t*~:(*>./-])t*1#.e.)@toupper    Main function
                          toupper    Convert to uppercase
                      e.     Build 2D array by comparing to itself
                   1#.       Row-wise sum; Count occurrences
                 t*     A) Filter by isupper (needed for finding max count)
           >./-]        Compute max of A) minus each element of A)
       ~:          Nub sieve; 1 if first occurrence, 0 otherwise
          *        Filter first occurrences only
     t*       Filter by isupper again, to ban non-alphabets from duplicating
   1+         Add one to preserve given chars
 #~           Duplicate
```
[Answer]
# [R](https://www.r-project.org/) + stringr, 108 bytes
I am not very good at `stringr`. Returns a mixture of lower and upper case since the question says it doesn't matter.
```
function(x){for(l in L<-letters)x=sub(l,strrep(l,max(s<-stringr::str_count(tolower(x),L))-s[L==l]+1),x,T);x}
```
[Try it online!](https://tio.run/##JcwxC8IwEIbh3V9ROiWYDK61Hdw7iLiJSI0XOYgXuVxrQPztMej2Pt/wcfG9LX4mJxhJZf32kVVokJqxtwFEgJPOQ5qvKpgkzPCs8ZiySr2tRrpz19W4uDiTKIkhvoDrkxm1tuk0DkM4rzfaZHPU2/wpXrV7xsgoCKnVq2qkJaKDPw7wQJGJHDS72/Kbyxc "R – Try It Online")
## Explanation
```
function(x){
for(l in letters){ # Iterate through builtin vector "a", "b", "c"...
   # Generate a 26-long integer vector for how many a's, b's, c's in lower case string
  s = stringr::str_count(tolower(x),letters)
    # Take the max of this
  m = max(s)
    # Repeat the letter in the iteration enough times to make the word 'fair'
  new.l = strrep(l,m-s[letters==l]+1)
    # Substitute the first instance only of the letter in the string for the repeated letter
    # This is case insensitive (the T at the end)
    # Notice we calculate the max letter frequency each loop
    # This is inefficient but doesn't change the answer and avoids bytes
  x=sub(l,new.l,x,T);
  }
x # Return the substituted string
}
```
[Answer]
# [K4](http://kx.com/download), 35 bytes
**Solution:**
```
{x@o@<o:(&^x),/(|/#:'g)#'g:" "_=_x}
```
**Examples:**
```
q)k){x@o@<o:(&^x),/(|/#:'g)#'g:" "_=_x}"Priorities"
"PPPrrioooritttieeesss"
q)k){x@o@<o:(&^x),/(|/#:'g)#'g:" "_=_x}"invoice"
"innvvooiccee"
q)k){x@o@<o:(&^x),/(|/#:'g)#'g:" "_=_x}"Remittance Notice"
"RRRemmmiittaaanncce Noootice"
```
**Explanation:**
Might be golfable with a different approach, will keep thinking
```
{x@o@<o:(&^x),/(|/#:'g)#'g:" "_=_x} / the solution
{                                 } / lambda taking implicit argument x
                                _x  / lowercase input
                               =    / group
                           " "_     / drop space from keys
                         g:         / save as g
                       #'           / take each
               (      )             / do this together
                  #:'g              / count occurances in each group
                |/                  / take the maximum
             ,/                     / flatten with
        (&^x)                       / indices where input is null (ie " ")
      o:                            / save as o
     <                              / indices to sort o ascending
   o@                               / apply these to o
 x@                                 / apply these indices to original input
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~33~~ 32 bytes
```
⭆↧θ⁺§θκ×ι∧№βι∧⁼κ⌕↧θι⁻⌈Ｅβ№↧θλ№↧θι
```
[Try it online!](https://tio.run/##bY1BCsIwEEX3niLLCcQTuCqiIFgQ9QJjOujQJLVNUnv7OLWrgrMZ5s//79sXDrZDV8pl4JDglmQ9a3zDufvQYDES9Nqoi8sRqnQKDU3QG9WKdmdPEdioKjSw77LEH0ax1oty6DO6CK1RR5Zzzfu5ag5CrXFinz3MpZJfQGu307P930c4y@xKuZLnlDBYUlUzsqVN2Y7uCw "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
  θ                                 Input string
 ↧                                  Lower case
⭆                                   Map over characters and join
      κ                             Current index
     θ                              Input string
    §                               Original character
   ⁺                                Concatenate with
        ι                           Lowercased character
       ×                            Repeated
            ι                       Lowercased character
           β                        Lowercase alphabet
          №                         Count
         ∧                          Logical And
                   ι                Lowercased character
                  θ                 Input string
                 ↧                  Lower case
                ⌕                   Find
               κ                    Current index
              ⁼                     Equals
             ∧                      Logical And
                       β            Lowercase alphabet
                      Ｅ             Map over characters
                           λ        Current character
                          θ         Input string
                         ↧          Lower case
                        №           Count
                     ⌈              Maximum
                    ⁻               Minus
                               ι    Lowercased character
                              θ     Input string
                             ↧      Lower case
                            №       Count
                                    Implicitly print
```
[Answer]
# Java 11, ~~190~~ ~~176~~ 162 bytes
```
s->{s=s.toUpperCase();char m=2,i=64,a[]=new char[127];for(int c:s.getBytes())m-=m+~++a[c]>>-1;for(;++i<91;)s=s.replaceFirst(i+"",repeat((i+""),m-a[i]));return s;}
```
-14 bytes thanks to *@Nevay*.
Output is in full uppercase.
[Try it online.](https://tio.run/##hVFNT9wwEL3zK0a51FY@IKhq1aZZqSAqFakU9eOU5jDrHcAQO5E9WbRCy19fnKwB9VD1EnlmXt7Me@8W15jfru52qkPv4Rtq@3AAoC2Tu0JFcDGVAD/ZaXsNSsSHl1Xobw/CxzOyVnABFmrY@Xzx4GtfcP97GMidoichK3WDDkx9nOn63dsMm7a2dA9TtymP37fVVe9E2Anqoy@uiU82TF5IafLapI9pio1qF4u8nHFVmupPH8pKTmscDV0484t2noVOkyQLHUIWcyEzk2OjWykrRzw6C77a7qrp6mFcduHqePy61yswQXzU17SAMirfeCZT9CMXQxhxZ4UtlEgune6dZk0@kbMZ/4ZqG/gV/Rf3g4xmRhts/7xav/4x23x4CGdm7JBpBechNSjLmEoRJQcmCeghlvthNndFMA74hsCjIVgGe3PVj9NkSQpHTy@U2ts3DL2FX1@/w4b4NeCY/F/sYeamDYBmpttbFr2eIt7DxEvae1wrn4MTyZ@jJAssUeh29wQ) (NOTE: `String.repeat(int)` is emulated as `repeat(String,int)` for the same byte-count, because Java 11 isn't on TIO yet.)
**Explanation:**
```
s->{                      // Method with String as both parameter and return-type
  s=s.toUpperCase();      //  Convert the input-String to full uppercase
  char m=2,               //  Max occurrence (+1), starting at 2
       i=64,              //  Index integer, starting at 64 ('A'-1)
       a[]=new char[127]; //  Create a count-array of size 127 (printable ASCII chars)
  for(int c:s.getBytes()) //  Loop over the characters of the String as integers
    m-=m+~++a[c]>>-1;     //   Increase the occurrence-counter of the char by 1 first
                          //   And if it's larger than the max-2, increase the max by 1
  for(;++i<91;)           //  Loop `i` in the range ['A', 'Z']
    s=s.replaceFirst(i+"",//   Replace the first char `i` in the string with:
       (i+"").repeat(     //   That same character repeated
        m-a[i]));         //   The max(+1) minus its array-occurrence amount of times
  return s;}              //  Then return the now modified String as result
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 15 bytes
```
ḟ§Ë#f√MṘO´πL¹m_
```
[Try it online!](https://tio.run/##ASoA1f9odXNr///huJ/Cp8OLI2biiJpN4bmYT8K0z4BMwrltX////0JlIGJlZXM "Husk – Try It Online")
Brute force, so very slow.
## Explanation
```
ḟ§Ë#f√MṘO´πL¹m_  Implicit input, say s = "To do"
             m_  Convert to lowercase: t = "to do"
           L¹    Length of s: 5
         ´π      All length-5 combinations of [1..5]:
                   [[1,1,1,1,1], [1,1,1,1,2], [2,1,1,1,1], ..., [5,5,5,5,5]]
        O        Sort them lexicographically:
                   [[1,1,1,1,1], [1,1,1,1,2], [1,1,1,1,3], ..., [5,5,5,5,5]]
      MṘ         For each, replicate letters of t that many times:
                   ["to do", "to doo", "to dooo", ..., "tttttooooo     dddddooooo"]
ḟ                Find the first string that satisfies this:
                   Example argument: x = "tto ddo"
    f√             Letters of x: "ttoddo"
  Ë                They have equal
 § #               number of occurrences in x: true (all have 2).
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt) `-h`, 27 bytes
*-3 bytes from @ETHproductions*
```
;v
ñ oC ó¥ ú £=iXÎpXèS)UbXg
```
---
**Trying to explain**
```
;v                          Convert implicit input to lowercase
ñ oC ó¥ ú £=iXÎpXèS)UbXg      Main function. Implicit lowercase input => "priorities"
ñ                           Sort => "eiiioprrst"
 oC                         Remove non alphabetical chars
   ó¥                       Split on different letters => ["e","iii","o","p","rr","s","t"]
     ú                      Right-pad each to the length of the longest with space => ["e  ","iii","o  ","p  ","rr ","s  ","t  "]
       £                    For each X in this array:
             XèS              Count the number of spaces in X
          XÎ                  Get the first character in X
            p   )             Repeat it (number of spaces) times
                              example the mapped value "e  " will become "ee"
         i                    Insert this into U at
                 UbXg           the first index of (first character in X) in U
        =                     Set U to the result
```
[Try it online!](https://tio.run/##AToAxf9qYXB0//87dgrDsSBvQyDDs8KlIMO6IMKjPWlYw45wWMOoUylVYlhn//8iUHJpb3JpdGllcyEiIC1o)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 89 bytes
```
->s{1while(a=s.scan /\w/).map(&g=->x{s.scan(/#{x}/i).size}).uniq[1]&&s[a.min_by &g]*=2;s}
```
[Try it online!](https://tio.run/##bY5NC4JAGITv/oqFwI/IFbvGCv2DiG4msdqmL@Rq@65fqb/dDCk6NMxhZg4Po6q4m25scgPs/SaDu7A5Q4oJl8Q7N55Dc17aZsrcoO2X3fZWfTt64FCEpxgdWkl4hH5kmhhymoO8xB0x02jNtjscp9A6ZYBkNidaoLY21kFBoUCDwLmArAtIxJyOIgetuUwE2V/rZeNkVmxF7xv9oIay0khuoYrG6RdjfDHGH4zxwbwA "Ruby – Try It Online")
I tried different approaches, but what really saves a lot of bytes is adding one character at a time.
### How:
```
->s{
    1while                             # 1 is a nop to the while
    (a=s.scan /\w/)                    # For all the letters in the string
    .map(&g=->x{s.scan(/#{x}/i).size}) # Count occurrences ignoring case.
    .uniq[1]                           # Break out of loop if all equals
    &&s[a.min_by &g]*=2                # Otherwise duplicate the letter
                                       #  with the lowest count
    ;s}                                # Return the string
```
[Answer]
# Powershell 6, 123 bytes
*It uses a char range `'a'..'z'`. See script for previous Powershell below.*
```
param($s)for(;'a'..'z'|%{
if($d=($s-replace"[^$_]").Length-$n){if($d-gt0){1}else{$s=$s-replace"^(.*$_)","`$1$_"}}}){$n++}$s
```
Explained test script:
```
$f = {
param($s)                               # a parameter string
for(;                                   # loop while exists at least one letter...
'a'..'z'|%{                             # for each letter
    $d=($s-replace"[^$_]").Length-$n    # let $d is a difference between a number of current letter and current $n 
    if($d-gt0){                         # if the difference > 0
        1                               # then return a object to increase $n on next iteration
    }
    if($d-lt0){                         # if the differenct < 0
        $s=$s-replace"^(.*$_)","`$1$_"  # append the current letter after a last instance of the letter. Use "^(.*?$_)" regexp to append it after a first instance of the letter.
    }
}){
    $n++                                # increment $n if exists at least one letter number of witch greather then $n
}                                       # and make next iteration of the 'for'.
$s                                      # return modified string if all letters in the string occur the same number of times
}
@(
    ,('Priorities', 'Ppprrioooritttieeesss', 'PPPriooorritttieeesss')
    ,('invoice', 'innvvooiccee')
    ,('Remittance Advice', 'Rrremmmiitttaannncce Adddvvvice', 'RRRemmmitttannnce Aadddvvviicce')
) | % {
    $s,$e = $_
    $r = &$f $s
    "$($r-in$e): $r"
}
```
Output:
```
True: Pppriooorritttieeesss
True: innvvooiccee
True: Rrremmmitttannnce Aadddvvviicce
```
# Powershell 5.1-, 133 bytes
```
param($s)for(;97..122|%{$_=[char]$_
if($d=($s-replace"[^$_]").Length-$n){if($d-gt0){1}else{$s=$s-replace"^(.*$_)","`$1$_"}}}){$n++}$s
```
[Answer]
# [Red](http://www.red-lang.org), 252 bytes
```
func[s][a: charset[#"a"-#"z"#"A"-#"Z"]t: parse s[collect[any[keep a | skip]]]m: copy
#()foreach c t[c: form c either n: m/:c[m/:c: n + 1][m/:c: 1]]d: last sort extract next
to-block m 2 foreach c s[prin c: form c if n: m/:c[loop d - n[prin c]m/:c: d]]]
```
[Try it online!](https://tio.run/##TY5NasMwEIX3PsVD3rQUU9KldrlByTJCC3U0xsK2JKRpaErv7so0JN0M72eYbwr77cTe2G7U2/gZyVRrnAZNrlQW0yunhl59q14dd3FWVjTyXqIaSsvCJMbFq5mZMxx@UOeQrbVrO5LyteufnsdU2NEEghjSaHZtmoNMXBA11ldNZh8aES842Js5WOs1FlcFNRUBf0lxJIhNdJKGjyXRjBVveBCqySVEPDBhvCOWlDI8BsTbkv3j@PbutieCEeq9hFSCBK6qu4chXlIg/peceA0iLhLj6C97t/0C "Red – Try It Online")
Ridiculously long solution...
## Explanation:
```
f: func [ s ] [
    a: charset [ #"a" - #"z" #"A" - #"Z" ]   ; letters
    t: parse s [                             ; parse the string 
        collect [ any [ keep a | skip ] ]    ; and keep only the letters
    ]
    m: copy #()                              ; initialize a map
    foreach c t [                            ; for each character in t
        c: form c                            ; the character as a string
        either n: select m c [ m/:c: n + 1 ] ; increase the count if already in map
                             [ m/:c: 1 ]     ; otherwise create a map entry with count 1 
    ]
    d: last sort extract next to-block m 2   ; convert the map to a block; extract only the 
                                             ; numbers and take the last of the sorted block
    foreach c s [                            ; for each character in the input
        c: form c                            ; the character as a string
        prin c                               ; print it (with no space nor newline)
        if n: select m c [                   ; if c is a key in the map
            loop d - n [ prin c ]            ; print the character again up to d times 
            m/:c: d                          ; set the count to max (flag it as used)
        ]
    ]
]
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~140~~ 137 bytes
```
x=>[...x=x.toLowerCase()].map(F=c=>(F[c]=-~F[c],F[c]>w?w=F[c]:w,c),w=0).map(c=>x=x.replace(c,c.repeat(c>'`'&c<'{'?w-F[c]+1:1),F[c]=w))&&x
```
[Try it online!](https://tio.run/##bYxBC4JAFITv/YrooLukS16tp4fAU4fuIrQ8n7GhrqyLKwT9dWvtFl1mBuabechJjmjUYONe17Q0sMyQlUKIGWZh9UU7Mmc5EuOV6OTACkDIWFFiBfHLW@Qlc7kDH1IXIY8cHPhKf1j/Y2hoJRLDCH0maRlm4S0M8BQ@w9zFfrpP0oSvb@A4D4J5OaLuR92SaPWdNWx3NUobZRWNO843v63qJ62Q/lWGOmWt7JG2sp6@0PIG "JavaScript (Node.js) – Try It Online")
+33 bytes from my first solution for those never-ending additional constraints. JS sucks at case-insensitive string manipulations you know.
-3 bytes back Thanks @Arnauld.
## Explanation
```
x =>                                     // The function.
  [...x = x.toLowerCase()].map(f = c => (// - Iterate among each character...
                                         // - Additional constraint 2
    f[c] = -~f[c],                       //   - Add one to the character counter
    f[c] > w ? w = f[c] : w,             //   - Update the maximum count if necessary
    c                                    //   - Return back the character for the use in
                                         //     the next map function
  ), w = 0)                              // - The counters
  .map(c =>                              // - Iterate again...
    x = x.replace(                       //   - Repeat the first appearance of
      c,                                 //   - Each character
      c.repeat(                          //   - Needed number times
        c > '`' & c < '{'                //   - Additional constraint 1
        ? w - f[c] + 1                   //   - If this is letter, repeat
        : 1                              //   - If not, stay as is
      ),                                 //   - That should've been clearly stated
      f[c] = w                           //   - And set the counter so that no further 
                                         //     replacements are done on this character 
    )                                    //   - (w - f[c] + 1 = 1 in further iterations)
  ) && x                                 // - Return the result
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~77~~ 70 bytes
```
{s:i|$($!.min(*{*}).key)|$/$/|until [==] ($!=.lc.comb(/<:L>/).Bag){*}}
```
[Try it online!](https://tio.run/##FY6xCsIwFEXn9iueEGxSJN0crBF0dhBXEakxlYdNIkkslLbfHtPpXg7nwv0q122jHmDdgoij3@FEKFlxjYaWYzkz/lEDm0hFqulnAnZwE@IOSRG8k1xa/aTVfnc@VIyfmjdLkzm21kFxcWgdBlS@2ECBprco1VKvSmMIjZEKjq9@gTDmWbpAPAggjzrPWko8S@mbhdb5HP8 "Perl 6 – Try It Online")
Taking G B's approach of inserting a character until all characters appear the same number of times. Receives a string that is modified in-place.
If underscores can be treated like letters, the regex can become `/\w/`, saving two bytes.
### Explanation
```
{
                    .lc.comb(/<:L>/).Bag          # Create Bag of letter/count pairs
                ($!=                    )         # Store temporarily in $!
 ... until [==]                          .values  # Until all counts are equal
 s:i|                      |    |                 # Replace (ignoring case)
     $($!.min(*.value).key)                       # letter with minimum count
                            $/$/                  # with itself doubled
}
```
[Answer]
# [Python 2](https://docs.python.org/2/), ~~97~~ 117 bytes
```
s=input().upper()
S=''
for c in s:S+=c+c*(max(map(s.count,map(chr,range(65,91))))-(S+s).count(c))*('@'<c<'[')
print S
```
[Try it online!](https://tio.run/##JY7BCsIwEETv@YrQyyZtLSgqKC3oH4g9eqrravfQJCRpqV9fU3wwMAwDM@4be2t2C9oXNVmWLaFh48aodDU6R15p0TYA4m29RMlGhnNbNFhgroZuTnIqVGhHE8vVY@9L35kPqeOhPG11YqPaIuh/R6HWuYIL1FjDA7Rwnk2U7ZKWBc2Ecv2R7xe4ebaeI1MAAWwmy0jJ3WngGDuDJK@v6Z91MvGEHw "Python 2 – Try It Online")
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~246~~ ~~223~~ ~~220~~ ~~210~~ ~~208~~ ~~193~~ 188 bytes
Compiler flag `-DF=;for(i=0;b[i];i++` `-DB=b[i]` (29 bytes)
Added mixed case support.
```
f(char*c){char m,i,s,*b,a[255]={0};s=asprintf(&b,c)F)B=tolower(B),a[B]++F,a[B]>a[m]?m=B:0)F)a[B]^a[m]?b=realloc(b,s+i),bcopy(&B,b+i+1,s),a[B]++:(m=B);puts(b);}
```
[Try it online!](https://tio.run/##NY5da8MgFIb/SulF0WohG/Sm4kal5HrsNmSgTtsDGoO6jhHy1@dMw67eD55zePVBOzlcS7FI32TcazwtuvEUaKJ7RWX3fDz2fGpmlrhMY4QhW7RTVOMWC56DC98mIoErKXpC2oe@yM73r56LU1Oxpfl4NIpHI50LGimaCGCqdBh/0E5QRYA80fT/5oTqMWbjV05IYTYXL2FAeLJoC8M9gDZbzGqoe0KEDCat@Q3G1bwbDznLQZvN@fO@8nP51dbJayqHi@Cqg76aljMbIgLesKVhQMgf "C (clang) – Try It Online")
[Answer]
# Pyth, ~~31~~ 30 bytes
```
JeSm/Qd=r0QVQ=tQ=+k*N-J/+kQN)k
```
[Try it here](http://pyth.herokuapp.com/?code=JeSm%2FQd%3Dr0QVQ%3DtQ%3D%2Bk%2aN-J%2F%2BkQN%29k&input=%22Priorities%22&debug=0)
### Explanation
```
JeSm/Qd=r0QVQ=tQ=+k*N-J/+kQN)k
       =r0Q                        Convert input to lowercase.
JeSm/Qd                            Find the count of the most common character.
           VQ               )      For each character in the input...
             =tQ                   ... remove that character from the input...
                =+k*N-J/+kQN       ... append copies to k until we have enough.
                             k     Output.
```
[Answer]
# [C (GCC)](https://www.gnu.org/software/gcc/) - 175 Bytes
```
f(char*s){int c[999]={0},i=0,m=0,k,L;while((L=s[i++])&&(k=++c[L<97?L+32:L]))m=k>m?k:m;i=0;while(L=s[i++])for(L=L<97&&L>64?L+32:L,putchar(L);isalpha(L)&&++c[L]<=m;)putchar(L);}
```
**Ungolfed**
```
f(char *s) {
  int c[999]={0},i=0,m=0,k,L;                      // Array used like a dictionary, temp vars
  while((L=s[i++])&&(k=++c[L<97?L+32:L]))          // store letter counts
    m=k>m?k:m;                                     // calculate max occurance
  i=0;                                             // reset string index
  while(L=s[i++])                                  // iterate string
    for(L=L<97&&L>64?L+32:L,putchar(L);isalpha(L)&&++c[L]<=m;) // set character L to lowercase if in alphabet, print always once, repeat if in alphabet
      putchar(L);                                  // print character
}
```
[Try it online!](https://tio.run/##dY4xT8MwEIX3/goTkGXjIEWAqFLXjRiRPCDWkCEyTnNK7FS2W4Yovz04UBBLh5Pe3b3v6am7vVLz3BDV1u7W0xFsQKrM87wSYzalILLUxOlSyT9b6DUhUvgSGKsoxqQTjKlSbvN1IdnD/UZWlBrR7UzRbQyP8Bn6Y5rBxWUBMJa7p8czlh6OYWlAJOXg6/7Q1lFi/J1ebYXh9J9jmpeWpgZLKBpXCDUkebGnAZR@zxLK4yW6PUl@dPy@OhgcBND@guFNGwihtkqj54/T5SA1DD1aenhUXF3f/LqcDkdnUcZX0/wF)
[Answer]
**Kotlin Android, 413 bytes**
```
var l: List<Char> = w.toList().distinct();val h = HashMap<Char, Int>();var x='m';var n=0;for(z in l.indices){var c=0;for (i in 0.rangeTo(w.length-1)){if(l[z]==(w[i]))c++};h.put(l[z],c);if(n<c){n=c}};for(entry in h){h.replace(entry.key,n-entry.value)};var v=ArrayList<Char>();for(i  in 0.rangeTo(w.length-1)){if(h.containsKey(w[i])){for(p in 0.rangeTo(h.get(w[i])!!)){v.add(w[i])};h.remove(w[i])}else{v.add(w[i])}}
```
[Try online](http://rextester.com/live/PCPID64484)
Explanation
step 1 --> Select list of distinct chars.
step 2 --> Get count of every char in string and select max char frequency.
step 3 --> get difference in frequency of chars with respect to max char frequency
step 4 --> place chars with respect to positions in string.
Happy Solving ! 
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 145 bytes
```
x=>x.ToLower().Select((a,b)=>x.IndexOf(a)==b&char.IsLetter(a)?a+new String(a,x.GroupBy(d=>x.Count(e=>e==d)).Max(d=>d.Key)-x.Count(d=>d==a)):a+"")
```
[Try it online!](https://tio.run/##hY7BTsMwEETvfEWVA/KqrT8AcKpSQRURBKJIPW/spVhq15W9oe7Xh7jAmevMe6OxaW6THx57tndJoufdrHng/kARuz39RnUtlMQM2dRZv4c2nCgq0BvakxWlcNZBaRp2lF8@FIIx3bX9xKib1JLISCMscMp0mmwui6OT9TqG/nh/Vq7Iq9CzKDI1GeMA9DPmUjj9RGeY//UlMQYBbnBaVTDcXm2jF2o9k/r5OoJsUVR5rKrX6MMIeEoVAPxHv9HBiyBbmizdl7d0kYZv "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [PHP](https://php.net/), ~~185~~ ~~173~~ 170 bytes
```
function($s){$m=max($a=count_chars($s=strtolower($s),1));foreach(str_split($s)as$c)$o.=str_repeat($c,($b=$a[$d=ord($c)])!=($a[$d]=$m)&&$d>96&&$d<123?$m-$b+1:1);return$o;}
```
[Try it online!](https://tio.run/##PZBhS8MwEIY/218Ry7EmWMUqCNplw38w/DrHyNLUBtZcuNymIP72mg70073v897xwsUhTst1HKJwREh7chGJffiQ96oV0As99adg2WOQkNQ3jHo0XxKMtngKvLeDoZQTnZgYj/jpaN6rG6XaHskZO8gc7VM8ep4Tk8AqwLv5YG5zJmNbSzhoMFvoNFKXgdqpay0vZKdhVIsFdKvnp3ksm4fHNYy3cLhpXhrVkuMTBcD2Z/qvFNviqtqQR/LsXarqbH04o7fuot/c6JlNsE68duc/uvGxKnbCJAEsVOHsgFnVohR6Jco6v0MCq@zfQ9lOvw "PHP – Try It Online")
Ungolfed (and un-ternaried and un-optimized).
```
function f($s) {
    $s = strtolower( $s );
    $a = count_chars( $s, 1 );
    $m = max( $a );
    foreach( str_split( $s ) as $c ) {
        if ( $c < 'a' or $c > 'z') {           // is non a-z
            $n = 1;
        } elseif ( $a[ord($c)] == $m ) {    // already has max number
            $n = 1;
        } else {
            $n = $m - $a[ord($c)] + 1;       // add this many chars
        }
        $o .= str_repeat( $c, $n );
        $a[ord($c)] = $m;                   // has reached the max
    }
    return $o; 
}
```
]