[Question]
  [
Inspired by this Stack Overflow question: [Sorting a list: numbers in ascending, letters in descending](https://stackoverflow.com/questions/45541119/sorting-a-list-numbers-in-ascending-letters-in-descending). Your task is to solve the following problem and, as this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), you should do so in as few as bytes as possible.
You should take a list of objects as input containing letters (any reasonable form: `string`, `char`, etc) and numbers. You should then sort the numbers into ascending order and the letters into descending order. However, you should keep letters in letter positions and numbers in number positions. For example, if the list is:
```
[L, D, L, L, D, L]
```
The output list should be in the form of:
```
[L, D, L, L, D, L]
```
**Workthrough**
Input: `['a', 2, 'b', 1, 'c', 3]`
* Sort the numbers into ascending order: `[1, 2, 3]`
* Sort the letters into descending order: `['c', 'b', 'a']`
* Join them back but keep the order the same: `['c', 1', 'b', 2, 'a', 3]`
**Rules**
* The list will only contain letters and digits.
* The list may be empty.
* The list may only contain letters or only digits.
* **If** your language does not support mixed type arrays you may use digit characters instead of numbers. Note that if your language does support this you must use mixed types.
* Letters will only be `[a-z]` or `[A-Z]`, you may choose which one.
* Letters are sorted as `a` being lowest, `z` being highest i.e. `a = 1, z = 26`.
* [Standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* I/O may be by any standard means including as a string.
**Test cases**
```
[5, 'a', 'x', 3, 6, 'b'] -> [3, 'x', 'b', 5, 6, 'a']
[ 3, 2, 1] -> [ 1, 2, 3 ]
[ 'a', 'b', 'c' ] -> [ 'c', 'b', 'a' ]
[] -> []
[ 2, 3, 2, 1 ] -> [1, 2, 2, 3]
```
As this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") the shortest answer in bytes wins!
  
[Answer]
# [Python 2](https://docs.python.org/2/), ~~53~~ ~~52~~ 51 bytes
-2 bytes thanks to g.rocket  
-1 byte thanks to Jonathan Frech  
-1 byte thanks to RootTwo
```
def F(x):n=sorted(x);print[n.pop(-(e>x))for e in x]
```
[Try it online!](https://tio.run/##NY0xDsIwDEV3TuEtieQiEQRDKzr2ElEGSlPRxYnSDOH0wS5i@Xr/68lOn/KOZFtbwgqTrqanxx5zCQvzkPJGxdE5xaQ7HcZqzBozBNgIqm/CJexFqnM3BPVUHJXjinBnnJVHJ8UiXAR/xizxUsCLjBb/Cnjfn@B4e1xmrRtZHiYt1bQv "Python 2 – Try It Online")
The `sorted` list will have the numbers first and then the chars like `[3, 5, 6, 'a', 'b', 'x']`, then use `e>x` to filter what is number and what is char, in python any number is less than a list (input) and a list is less than a string.
[Answer]
# [Retina](https://github.com/m-ender/retina), 10 bytes
```
O`\d
O^`\D
```
[Try it online!](https://tio.run/##K0otycxL/P/fPyEmhcs/LiHG5f//RKMkw2RjAA "Retina – Try It Online")
The `O` stage in Retina can directly perform the kind of selective sorting required by this challenge.
Here the first line sorts digits while the second line sorts non-digits in reverse.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), ~~27~~ 26 bytes
Expects characters to be uppercase
```
(⍋⊃¨⊂)@(~e)(⍒⊃¨⊂)@(e←∊∘⎕A)
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R2wSNR73dj7qaD6141NWk6aBRl6oJFJmEJJIKVPSoo@tRx4xHfVMdNYG6FEx1FNQd1YFEBJAw1lEwAzKd1LnSQGwjHQVDIAsi7wQinEEyj3rXAAA "APL (Dyalog Unicode) – Try It Online")
This is just two applications of the form `f@g`, apply the function `f` on the items indicated by `g`.
For the first application we use:  
 `f`: `⍒⊃¨⊂` the descending grades (`⍒`) each pick (`⊃¨`) from the entire argument (`⊂`).  
 `g`: `(e←∊∘⎕A)` members (`∊`) of (`∘`) the **A**lphabet (`⎕A`), and store (`←`) this function as `e`.
For the second application we use:  
 `f`: `⍋⊃¨⊂` the ascending grades (`⍋`) each pick (`⊃¨`) from the entire argument (`⊂`).  
 `g`: `(~e)` not (`~`) members of the alphabet (`e`; the function we stored before)
[Answer]
## JavaScript (ES6), ~~71~~ ~~51~~ 47 bytes
*Saved 20 bytes by just using `sort()`, as suggested by [@JustinMariner](https://codegolf.stackexchange.com/users/69583/justin-mariner)*  
*Saved 4 more bytes thanks to [@CraigAyre](https://codegolf.stackexchange.com/users/68610/craig-ayre)*
Using a similar approach as [Rod's Python answer](https://codegolf.stackexchange.com/a/138208/58563):
```
a=>[...a].map(n=>a.sort()[1/n?'shift':'pop']())
```
### Test cases
```
let f =
a=>[...a].map(n=>a.sort()[1/n?'shift':'pop']())
console.log(JSON.stringify(f(['a', 2, 'b', 1, 'c', 3]))) // -> ['c', 1', 'b', 2, 'a', 3]
console.log(JSON.stringify(f([5, 'a', 'x', 3, 6, 'b']))) // -> [3, 'x', 'b', 5, 6, 'a']
console.log(JSON.stringify(f([3, 2, 1]))) // -> [ 1, 2, 3 ]
console.log(JSON.stringify(f(['a', 'b', 'c']))) // -> [ 'c', 'b', 'a' ]
console.log(JSON.stringify(f([]))) // -> []
console.log(JSON.stringify(f([2, 3, 2, 1]))) // -> [1, 2, 2, 3]
```
[Answer]
# [R](https://www.r-project.org/), ~~83~~ 76 bytes
*-7 bytes thanks to Miff*
```
function(n){u=unlist
d=n%in%0:9
n[d]=sort(u(n[d]))
n[!d]=sort(u(n[!d]),T)
n}
```
This is the same as the below, but it allows for mixed-type input as a `list` rather than an `atomic` vector (which would typecast everything as characters with mixed types).
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jT7O61LY0LyezuIQrxTZPNTNP1cDKkisvOiXWtji/qESjVAPE1tQECikiiwE5mjohQOHa/2kaIO0aSolKOkY6SklKOoY6SslKOsaamv8B)
# [R](https://www.r-project.org/), ~~68~~ 61 bytes
*-7 bytes thanks to Miff*
```
function(n){d=n%in%0:9
n[d]=sort(n[d])
n[!d]=sort(n[!d],T)
n}
```
Anonymous function. All digits are cast to characters in this case. `n[-d]` is the array without the digits. Returns `NULL` (empty list) on empty input.
[Try it online!](https://tio.run/##K/qfZvs/rTQvuSQzP08jT7M6xTZPNTNP1cDKkisvOiXWtji/qEQDxNIE8hURAkCmTghQrPZ/mkayhlKiko6RjlKSko6hjlKyko6xpiYXSFxT8z8A)
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~18~~ 15 bytes
*Thanks @Shaggy for -3 bytes and for help fixing for arrays with `0`s.* 
```
c ñc
®¤?Vv :Vo
```
First line is intentionally left blank.
[Try it online!](https://codepen.io/justinm53/full/NvKjZr?code=CmMg8WMKrqQ/VnYgOlZv&inputs=WzUsICdhJywgJ3gnLCAzLCA2LCAnYidd,WzMsIDIsIDFd,WydhJywgJ2InLCAnYydd,W10=,WydzJywgNSwgJ2EnLCAneCcsIDMsIDAsIDYsICdiJ10=&flags=LVE=) using `-Q` to view the formatted array.
## Explanation
First line is blank to avoid overwriting the input array.  
`[5, 'a', 'x', 3, 6, 'b']`
```
c ñc
```
Make a copy by flattening (`c`) the input array, then sort (`ñ`) with strings represented by their char code (`c`). This is stored in `V`.  
`[3, 5, 6, 'a', 'b', 'x']`
```
£
```
Then map the input array by the function...
```
¤?Vv :Vo
```
Turn numbers into binary strings (truthy) or strings into `""` (falsy) (`¤`). If truthy, remove from the start of `V` (`v`), otherwise remove from the end (`o`).
[Answer]
# JavaScript, ~~164~~ ~~162~~ ~~158~~ 142 bytes
edit 1: 2 bytes less after removing a redundant assignment of v.
edit 2: 4 bytes less thanks to TheLethalCoder.
edit 3: 16 bytes less thanks to brilliant hints from Justin Mariner
```
x=>eval("n=v=>typeof(v)=='number';l=x.length;for(i=0;i<l;x[i++]=x[m],x[m]=w){for(v=w=x[j=m=i];++j<l;)n(e=x[j])==n(w)&&e<v==n(w)&&(m=j,v=e)}x")
```
It's my very first time in code-golf, so it can surely be improved... But still, worth a try.
The program performs a variant of selection sort, which only takes into account the values of the same type as the current one (swapping only a number and a number, or a letter and a letter)
Readable form:
```
x=>eval("
    n=v=>typeof(v)=='number';
    l=x.length;
    for(i=0;i<l;x[i++]=x[m],x[m]=w){
        for(v=w=x[j=m=i];++j<l;) 
            n(e=x[j])==n(w) && e<v==n(w) && (m=j,v=e)
    }
    x
")
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
OÞḢṪOƑ}?Ɱ
```
[Try it online!](https://tio.run/##y0rNyan8/9//8LyHOxY93LnK/9jEWvtHG9f9dzvcfnTSw50zNCP//4821VFQT1QHEhVAwlhHwQzITFKP1VGIBvGMdBQMwWyImiQQkayuABICCxvpwFQpxAIA "Jelly – Try It Online")
Takes input as a flat array (Jelly typically treats strings as char arrays, so `[5, 'a', 'x', 3, 6, 'b'] -> [5, ['a'], ['x'], 3, 6, ['b']]`. The Footer flattens this array for you).
Similar to [PurkkaKoodari](https://codegolf.stackexchange.com/users/30164/purkkakoodari)['s Jelly answer](https://codegolf.stackexchange.com/a/138213/66833)
## How it works
```
OÞḢṪOƑ}?Ɱ - Main link. Takes an array A on the left
 Þ        - Sort by:
O         -   Ordinal
            This shuffles the strings to the end,
             sorting both the strings and the numbers
        Ɱ - Over each element E in A:
       ?  -   If statement:
    OƑ}   -     Condition: E is a number?
  Ḣ       -     Then: Pop and yield the first element of A sorted
   Ṫ      -     Else: Pop and yield the last element of A sorted
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 bytes
```
FOÞɓṪ}Ḣ}ẇØa$?€
```
[Try it online!](https://tio.run/##y0rNyan8/9/N//C8k5Mf7lxV@3DHotqHu9oPz0hUsX/UtOb////RpjoK6onqQKICSBjrKJgBmUnqsQA "Jelly – Try It Online")
Basically a port of [Rod's Python solution](https://codegolf.stackexchange.com/a/138208/30164).
[Answer]
# q/kdb+, ~~54~~ 53 bytes
**Solution:**
```
{x[w,q]:asc[x w:(&)d],desc x q:(&)(~)d:-7=type@/:x;x}
```
**Examples:**
```
q){x[w,q]:asc[x w:(&)d],desc x q:(&)(~)d:-7=type@/:x;x}(5;"a";"x";3;6;"b") / mixed list
3
"x"
"b"
5
6
"a"
q){x[w,q]:asc[x w:(&)d],desc x q:(&)(~)d:-7=type@/:x;x}3 2 1   / simple list
1 2 3
q){x[w,q]:asc[x w:(&)d],desc x q:(&)(~)d:-7=type@/:x;x}"abc"   / simple list
"cba"
q){x[w,q]:asc[x w:(&)d],desc x q:(&)(~)d:-7=type@/:x;x}2 3 2 1 / simple list
1 2 2 3
```
**Explanation:**
Find the chars in the list, sort descending, find the longs in the list, sort them ascending, join to get a list of, e.g. `("x";"b";"a";3;5;6)`, then assign the sorted values back to their original positions in the list, e.g. at `0 3 4 1 2 5`.
Golfing is just switching out q keywords (`each`, `where` and `not`) for their `k` equivalent (which requires them to be wrapped in brackets).
```
{x[w,q]:asc[x w:where d],desc x q:where not d:-7=type each x;x} / ungolfed
{                                                           ; } / lambda function with 2 statements
                                                 type each x    / return types of elements in mixed list
                                              -7=               / true where item is a long
                                            d:                  / save this bool array in d
                                        not                     / invert
                                  where                         / indices where true (we have chars)
                                q:                              / save these indices in q
                              x                                 / values of x at these indices
                         desc                                   / sort them descending
                        ,                                       / join/contatenate
                where d                                         / indices where we have digits
              w:                                                / save this in w
            x                                                   / values of x at these indices
        asc[           ]                                        / sort them ascending
 x[w,q]:                                                        / assign this list to x at indices w,q
                                                             x  / return x
```
**Edits**
* -1 byte as don't need square brackets around `desc`
[Answer]
# [C++17 (gcc)](https://gcc.gnu.org/), 219 bytes
```
#include <variant>
#include <set>
using V=std::variant<char,int>;void f(V*a,V*b){std::set<V>S[2];for(V*c=a;c<b;++c)S[c->index()].insert(*c);auto
C=S->rbegin();auto N=S[1].begin();for(;a<b;++a)*a=(a->index()?*N++:*C++);}
```
[Try it online!](https://tio.run/##bZBNa4NAEIbv/oohhcZ1NZCWtuCqPeSei@DFehjXjy6YNegqKeJfr101bVPoHIbdmXee@eDns1NyPk13QvKqy3LwemwEShUYv6E219@uFbKEyG9V5rpXkcffsbGFVrO@FhkUZmShHVkpGRaZLvSiIIwfElbUjU5yHxn3UkYpJ2HMnUDILL@YJNkJ2eaNMi1OGHaqNg5@6ARNmpdCmmsIjn4Y75Pdd2wmMlxgSCz0TfzBvVpHSl3rQClh43Sziahb1eR4ut2uU6IS6iMw9B5wwpkNgwHaIshQYZyADwM82bDFrXYX7R5teNbPdAsjW6SFCetccwWxIZfZ@gSyCpZ78LpT4HmwGWBzrasbMHktWwXRPfTgLi3JkputF61QJsTJVTQfQuuw0jP@ZerYgtZkGG2N@rfx@CZ159GYPnlRYdlOjs77nNL9yxc "C++ (gcc) – Try It Online")
Hardly competitive. But I must support mixed-type arrays? FINE.
Accepts an array of variants in range style, and modifies it in place. Copies the input into two sorted sets, and then back into the input/output array.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 9 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
I *knew* there had to be a (golfy) way to do this without any sort of conditional :)
Outputs an array of singleton arrays. Replace `£` with `c@` to output a flat array.
```
£=ñs)jÓXÌ
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=oz3xcylq01jM&input=WzUgImEiICJ4IiAzIDYgImIiXQotUQ)
```
£=ñs)jÓXÎ     :Implicit input of array U
£             :Map each X (or flat map with c@)
 =            :  Reassign to U
  ñ           :    Sort by
   s          :      Converting to string if an integer, slicing if a string (which does nothing to the string if given no arguments)
    )         :  End reassignment
     j        :  Remove (mutating the original) and return the element at modular 0-based index
      Ó       :    Bitwise NOT of the negation of (i.e, decrement)
       XÎ     :    Sign of difference of X with -1 if an integer, last character if a string (resulting in 0 if an integer or -1 if a string)
```
[Answer]
# Mathematica, 203 bytes
```
(K=Reverse;B=Complement;L=Length;S=Position[#,_Integer];T=Sort@Cases[#,_Integer];G=K@B[#,T];V=B[Range@L@#,Flatten@S];R=K@Sort@#;Table[R[[Min@S[[i]]]]=T[[i]],{i,L@T}];Table[R[[V[[i]]]]=G[[i]],{i,L@G}];R)&
```
  
[Try it online!](https://tio.run/##VYvBasMwDEDv@4rhwOhAl620FyMwKSyMZlAc04sxxSlqakicEZsxKPn21ARGF4FAvPfU2Xh15zBdcFrtUdIPDYF4jru@@26pIx95iSX5Jl55hYc@uOh6rzM4ffpIDQ2GK6z6IYqdDRQWosC9yBNRhh8x19L6hkQpMvhobYzkRWW4TM38nnFl65a01PrLJaW1M2lQzQfcHJRCjeZRHf@K4l9RpEK@vkyHwfn4LC76tgFmGbBfBmvYAqvZaJ4ednZ12vOSr@Ed3hZkNNMd "Mathics – Try It Online")
[Answer]
# [Pyth](https://pyth.readthedocs.io), ~~12~~ 11 bytes
```
KSQm.(Kt>\@
```
**[Try it online!](https://pyth.herokuapp.com/?code=KSQm.%28Kt%3Cd%5C%40&input=%5B%275%27%2C+%27a%27%2C+%27x%27%2C+%273%27%2C+%276%27%2C+%27b%27%5D&test_suite_input=%5B%275%27%2C+%27a%27%2C+%27x%27%2C+%273%27%2C+%276%27%2C+%27b%27%5D%0A%5B+%27a%27%2C+%27b%27%2C+%27c%27+%5D%0A%5B%5D&debug=0) or [Try the Test Suite.](https://pyth.herokuapp.com/?code=KSQm.%28Kt%3E%5C%40&test_suite=1&test_suite_input=%5B%275%27%2C+%27a%27%2C+%27x%27%2C+%273%27%2C+%276%27%2C+%27b%27%5D%0A%5B+%27a%27%2C+%27b%27%2C+%27c%27+%5D%0A%5B%5D&debug=0)**
---
# Explanation
```
KSQm.(Kt<d\@  - Full program with implicit input.
KSQ           - Assign a variable K to the lexicographically sorted input.
   m          - Map over the input (with a variable d).
    .(K       - Pop the sorted list at this location:
       >\@    - If d is lexicographically lower than '@', at 0 (the first element). Else, at -1 (the last element).
```
[Answer]
# Python, ~~145~~ ~~139~~ 130 bytes
*6 bytes saved thanks to @officialaimm*
*9 bytes saved thanks to @Chris\_Rands*
```
g=lambda s,a:sorted(x for x in s if(type(x)==str)==a)
def f(s):l,n=g(s,1),g(s,0)[::-1];return[[n,l][type(x)==str].pop()for x in s]
```
[Try it online!](https://tio.run/##TY7LDsIgEEXX8hWzKySjsRpdYPBHCAu0RZsgJYAJfn2d1kTd3HncM4/4Kvcx7Kfpprx9XDoLGa3MYyp9xyu4MUGFIUCGwfHyij2vQqlcEqkVrOsdOJ6F9BjUjWdsBc5hK7SU69acUl@eKWgd0Bv9P282cYxc/A6YyYMCzVb6gNDYhqSS7BGOlF4ag2Qt/d1SI7QUrzOyWDNJTvspPgtmihBYeoYZ9j3nJVvFNITCKyHqTKCj18T0Bg)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 17 bytes
```
SaJ¹á{R¹þ{«vyay.;
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/ONHr0M7DC6uDgOS@6kOryyoTK/Ws//9Pqyw1sTDLtLQwBwA "05AB1E – Try It Online")
---
```
SaJ               # Push 1 if letter 0 else, for all letters in string.
   ¹á{R           # Reverse sort letters from input.
       ¹þ{        # Regular sort digits from input.
          «       # Concatenate those two things.
           v      # For each letter in the sorted string...
            ya    # 0 if digit, 1 if letter.
              y.; # Replace first instance of 0/1 with digit/letter.
```
---
Using the sort-by closure actually was worse: `Σ©Ç®ai0<*}}¹SaJsvyay.;`
[Answer]
## Haskell, 108 bytes
There may be shorter ways, but I just had to try it with the `Lens` library.
```
import Control.Lens
import Data.List
i(!)f=partsOf(traverse.filtered(!'='))%~f.sort
f x=x&i(<)id&i(>)reverse
```
I could define `f` to just be the composition of the two `i` invocations, but I'd still have to apply `x` to it to avoid a type error from the monomorphism restriction. Note that the type of `f` is `Traversable t => t Char -> t Char` so it can be used with `String`s which are lists of `Char`s as well as with arrays of `Char`s.
Here are the test cases:
```
*Main> map f ["5ax36b","321","abc","","2321"]
["3xb56a","123","cba","","1223"]
```
[Answer]
# Python 3, 77 bytes
This answer is based on the comment that says you can use '1', '2', etc if chars and digits are not comparable in the language. 'a' and 1 are not comparable in Python 3.
```
def f(s):x=sorted(s,key=lambda c:ord(c)-95);return[x.pop(-(c>'.'))for c in s]
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 125 113 110 bytes
```
main(i){char*b,*c,s[99];for(gets(c=b=s);*++c||*(c=++b);)i=*b&64,i^*c&64||*c>*b^!i&&(i=*c,*c=*b,*b=i);puts(s);}
```
[Try it online!](https://tio.run/##FczBCsIwEIThu2/hJWQ38aQWSoigTyGIhe6gdQ9VafRkffa4nobhhw@rAah17PXulT649RNLZMRyattzuj4mP1xexSNLLpQ4BMwz2w1BKJFmFtdsonYMW0vYsXRLdc5bg0n570lWSs@3QYZ8a93uj@vmsPgB "C (gcc) – Try It Online")
**Explained:**
```
main(i)
{
    char*b,*c,s[99];
    // slightly modified stupid bubblesort, this line in fact
    // does nested looping with a single for statement
    for(gets(c=b=s);*++c||*(c=++b);)
    // (undefined behavior here, there's no sequence point between accesses to c,
    // so this could go wrong. Works with the gcc version on tio.)
        // determine whether the current b is a letter:
        i=*b&64,
        // for doing anything, b and c must be the same "type":
        i^*c&64
            // when c > b for letter or c <= b for digit
            || *c>*b^!i
            // then swap
            && (i=*c,*c=*b,*b=i);
    puts(s);
}
```
Letters are expected in uppercase.
[Answer]
# PHP, 66 bytes:
```
for($a=$argv,sort($a);a&$c=$argv[++$i];)echo$a[$c<A?++$k:--$argc];
```
takes input from command line arguments, prints a string.
Run with `-nr` or [try it online](http://sandbox.onlinephpfunctions.com/code/0db1a4c24000e852a95ab9e6ad87ec30ce45c924).
Yields a warning in PHP 7.1; replace `a&` with `""<` to fix.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 26 bytes
```
a[⍒i][⍋⍋27>i←(⎕a,⌽⍳9)⍳a←⎕]
```
(uses `⎕IO=1`)
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob2pm/qO2CYYgFpBWSIx@1DspMxZIdgORkbldJlBUAyiZqPOoZ@@j3s2WmkAiESgIFIv9/1/dUV1HwUhHQd0JSBsCaWcgbQwA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Uiua](https://uiua.org), 24 [bytes](https://codegolf.stackexchange.com/a/265917/97916)
```
⍜▽(⊏⍏.)¬⊃∘⍜▽(⊏⍖.)⊐∵type.
```
[Try it!](https://uiua.org/pad?src=0_1_0__ZiDihpAg4o2c4pa9KOKKj-KNjy4pwqziioPiiJjijZzilr0o4oqP4o2WLiniipDiiLV0eXBlLgoKZiB7NSBAYSBAeCAzIDYgQGJ9CmYgezMgMiAxfQpmIHtAYSBAYiBAY30KZiB7MiAzIDIgMX0K)
```
⍜▽(⊏⍏.)¬⊃∘⍜▽(⊏⍖.)⊐∵type.
                       .  # duplicate
                 ⊐∵type   # mask of types (0 for number, 1 for character)
          ⍜▽(⊏⍖.)         # descending sort the characters
        ⊃∘                # keep the mask
       ¬                  # not
⍜▽(⊏⍏.)                   # ascending sort the numbers
```
[Answer]
# [K (ngn/k)](https://codeberg.org/ngn/k), 26 bytes
```
{x[>i]@<<1>i:x*1 1'`c=@'x}
```
Derived from @ngn's APL solution
[Try it online!](https://ngn.codeberg.page/k#eJxLs6quiLbLjHWwsTG0y7Sq0DJUMFRPSLZ1UK+o5eJKczDVUUpU0lGqUNIx1jHTUUpSAoqZKBgrmCsYKRgD2UpJiUUgMUUDANktEfw=)
[Answer]
# Mathematica, 107 bytes
```
(s=#;s[[p]]=Sort[s[[p=#&@@@s~($=Position)~_String]],#2~Order~#>0&];s[[c]]=Sort@s[[c=#&@@@s~$~_Integer]];s)&
```
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 171 bytes
```
a=>{var b=a.Where(x=>x is int).ToList();b.Sort();int i=0,j=0;return a.Select(x=>b.Contains(x)?b[i++]:a.Except(b).OrderByDescending(y=>y).ToList()[j++]);}
```
Byte count also includes:
```
using System.Linq;
```
[Try it online!](https://tio.run/##jVJNb9swDL37VxC9REI8oR/oDnXlYVvToUCLHVKghyAHSWFWBY6USXLrIPBvz6R4q@ftkPJA0PTjE/lI5T8o63Bfe21@wHTrA67ZV1tVqIK2xrNvaNBpVWQDxL02P4ssM2KNfiMU/s5nuwyiqUp4D58PcZdJ5oMIWsGL1Qt4ENoQ@varByXLBl@3tVHX99qHaytXsasyh7uJqdfohKzwT7KEJfC94OXuRTiQXLCnZ3RIGl42oD1oEyh7tImH0EKyqXUpiGnQ/DRf8dPCYaidAcGmmKZPpTJKYULs1ZOGfpIzPR7PrwSbNAo3gUjKvrsFui/bG/QKzSIKRLa83PYvzVaxghbtvhjMlHrUZlMH4GDwFbohZvPZfAAbypLsbzDs4DKHkRhF10R3kcPHGMoRtPmxwog9z@HsHciOXyan3sN8HHGe988PsG0x3PwyHqZQz@SgVtSrk4wekWhJ9Jv8/SLYrXWTRNYALyFu1dsK2ZPTId4IjOEETigt/iMbAOPRI/kH1E/QRW3W7n8B "C# (.NET Core) – Try It Online")
Explanation:
```
a =>
{
    var b = a.Where(x => x is int).ToList(); // Filter to only ints and transform to list
    b.Sort();                                // Sort the list
    int i = 0, j = 0;                        // Create index counters
    return a.Select(x =>                     // Replace each input element with
                    b.Contains(x) ?          // If it is in list b:
                    b[i++] :                 // Get the next element from b
                    a.Except(b)              // Otherwise take input and filter out those in b
                     .OrderByDescending(x=>x)// Order them z to a
                     .ToList()[j++]);        // Get the next element
```
[Answer]
# [Perl 5](https://www.perl.org/), 107 + 1 (-n) = 108 bytes
```
y/][//d;@a=split/, /;@l=sort grep/\D/,@a;@d=sort grep/\d/,@a;@r=map{/\d/?pop@d:shift@l}@a;$"=", ";say"[@r]"
```
[Try it online!](https://tio.run/##TcmxDsIgFIXhVyHEpAv1tpouEuIdXH0C7IBSlQTLDbA0xlcXMS5OX85/aIp@KGWBUQNYiUYl8i6DYCDRqxRiZrc4EZwOINBItP/N/lpUD0PP79xTILS7dHfXjP5VzxVXXDAuk1m4xjjyUnRjGsE2gjXnal@9VLfjO1B2YU6lPQ7rru9KO38A "Perl 5 – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 265 bytes
```
x.sort_by(&:to_s).select{|a| a.is_a?(String)}.zip(x.map.with_index {|a, i| a.is_a?(String) ? i : nil}.compact).each{|a,i| x[i] = a}
x.sort_by(&:to_s).select{|a| a.is_a?(Integer)}.zip(x.map.with_index {|a, i| a.is_a?(Integer) ? i : nil}.compact).each{|a,i| x[i] = a}
```
[Try it online!](https://tio.run/##jc6xCoMwEIDhvU9xOBQFOWi7CeLcuaNIONOgBxolSWls9dnTdOjUxelfvuE3j3YJvqwTmeRwyiGh2EtsG3tugkc7GSfaJT0WbhI2Q6sGJd17pRUI2Qqq0pszrLtswxfPqceRZnyy6wXru/IQaQ78p6EChgI0DxvKaZxJugwVyf7rI/c1N1ACbYddD1ftVKfM3okf330RZvDhAw "Ruby – Try It Online")
First timer here, My solution is definetly not the best one. But since this is my first answer, I thought in posting just for the fun of it.
Looking foward to see better Ruby answers, to see what is the best approach. I hope I improve in future answers =)
Readable
```
x = ["c", 1, "a", 3, "b", 2]
b = x.map.with_index {|a, i| a.is_a?(Integer) ? i : nil}.compact
s = x.map.with_index {|a, i| a.is_a?(String) ? i : nil}.compact
o = x.sort_by(&:to_s).select{|a| a.is_a?(Integer)}
d = x.sort_by(&:to_s).select{|a| a.is_a?(String)}
d.zip s
d.zip(s).each {|a, i| x[i] = a}
o.zip b
o.zip(b).each {|a, i| x[i] = a }
p x
```
[Answer]
# Python 3, 91 bytes
```
def f(s):x=sorted(s,key=lambda c:(type(c)==str,c));return[x.pop(-(type(c)==str))for c in s]
```
[Answer]
## Clojure, 151 bytes
```
#(map(fn[t c](nth((if(=(type 1)t)vec reverse)(sort((group-by type %)t)))(-(c t)1)))(map type %)(reductions(partial merge-with +)(for[i %]{(type i)1})))
```
Example:
```
(def f #( ... ))
(f [5 \a \x 3 6 \b])
; (3 \x \b 5 6 \a)
```
This calculates the cumulative ~~sum~~ count of integers and characters, and uses it to lookup the correct element from a sorted list of corresponding type's elements.
[Answer]
# [Zsh](https://www.zsh.org/), 43 ~~55~~ ~~70~~ ~~95~~ bytes
```
b=(${(n)@});for i;echo $b[$[#i>64?--k:++j]]
```
[Try it online!](https://tio.run/##JYvBCoMwGIPvPkXQHiyiTJ0eJtt8DxG0YtWNrcNWGHN99u6HXZJ8Cfno2cmQ795E4sQ5ZHv45LXllVQrlmocZgUmGtYEy6U8XuP4foqiW9s6W01g9XfVFkGSJN2qO9Dn0RsNM49Qm3ltxvMkemQQSDEgx4G4oOZNuYQgymlNyX2fJPuj@wE)
  ~~[55bytes](https://tio.run/##NYvbCoMwGIPvfYqgIi2iTN28KRu@xxC04mljc7QVxqzP3v0wdpPkS8hHT25gfPNGEifPLNzYk1c7F8OiMAvGgvlSHjmPor6bFoTymiT32to/xfGtdrsYEVZW6R1BmqaN0g3o/2iNhpl6LKt5rcbzBrTIIZGhQ4ED8YmaN@USkqigNSP3fZL8h@4L)~~
  ~~[70bytes](https://tio.run/##RYzdCoJAFITvfYpBRXaRLLW8kcL3EEFX/I0y3JVC3WffDnTRzcz5Zg6zyt60jG9WR2LElbkbe/JM87SdZgwpY85wS86ce15T9xNckfv@3aevN3eyY14d1kIX@/4vx8LotIOb7bPUcIIgKGdZguYelZJQfYNpUa9FWVaLChEEQtSIcSK@UPKhO4EgiqkNyW2bJPqh@QI)~~
  ~~[95bytes](https://tio.run/##RYvLCoMwEEX3@YrBBkkIEh@t0Jq2/kfIIla0KrSgm2Kab08HsuhiZu45w923ZxgYdyNOsFdGHXvxVuo8OxvPof8bm@1oyPBeYWoYO0y3@ngXYrkIMXOepkop6qibYlfSXs/Gx5qkVi/GB9@MQNvvunlCBrBQQgcFPKCCHPmE5oO5hg6pwm@BN0lwlRHDDw "Zsh – Try It Online")~~
Create a sorted array `b`, numbers first. Iterate over the arguments. If `i` is a letter (>ascii #64) then decrement `k` and print `b[k]`, (e.g. `b[-2]` is the 2nd to last value). If `i` is a number, increment `j` and print `b[j]`.
NB: Previously I forgot to **decrease** letters. Fixed now, and saved bytes!
]