[Question]
  [
This challenge is inspired by [this](https://codegolf.stackexchange.com/a/112832/31516) very nice answer by TidB.
---
In TidB's answer, every eight character is in the correct order: `gnilwoB edoC` (`Code Bowling` backwards). The other strings however ~~are~~ were in a strange, random order.
Your challenge is to fix this.
Take a (non-empty) string and a positive integer `n` as input. The string will contain ASCII characters in the range: 32-126 (space to tilde).
You must sort the string in **ascending** order (seen from the left, based on the ASCII-code value), but skip every `n`th character, starting from the end of the string. As an example, let's take the string `abcdABC123` as input, and `n=4`, then we'll get: 
```
abcdABC123   <- Input string. (n=4)
_b___B___3   <- These will not be sorted (every 4th starting from the end)
1_2AC_acd_   <- The remaining characters, sorted
1b2ACBacd3   <- The final string (the output)
```
Another example:
```
9876543210   <- Input string (n=2)
_8_6_4_2_0   <- These will not be sorted
1_3_5_7_9_   <- The remaining characters, sorted
1836547290   <- The final string (the output)
```
The input string can be taken on an optional format (string, list of characters, list of single character strings ...). The input integer can also be taken on an optional format.
**Test cases:**
The format will be `n=__`, followed by the input string on the next line. The output is on the line below.
```
n=1   (All elements will stay in place)
nafgaksa1252#"%#
nafgaksa1252#"%#    
n=214  (The last character will stay in place. All other are sorted. 
&/lpfAVD
&/AVflpD  
n=8
g7L9T E^n I{><#ki XSj!uhl y= N+|wA}Y~Gm&o?'cZPD2Ba,RFJs% V5U.W;1e  0_zM/d$bH`@vKoQ 43Oq*C
g       n !#$%&'i*+,./01l234579;w<=>?@ADoEFGHIJKBLMNOPQR STUVWXYeZ^_`abcdhjkmqsuovyz{|}~C
```
  
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~15~~ 14 bytes
```
ttfiX\qgP)S5M(
```
Inputs are a string enclosed in single quotes and a number. Single-quote symbols in the string should be escaped by duplicating (as in MATLAB and Octave).
[Try it online!](https://tio.run/##y00syfn/v6QkLTMipjA9QDPY1Ffj/3/1xKTkFEcnZ0MjY3UuEwA "MATL ‚Äì TIO Nexus") Or [verify all test cases](https://tio.run/##y00syfmf8L@kJC0zIqYwPUAz2NRX479LyH/1vMS09MTs4kRDI1MjZSVVZXUuQy51Nf2cgjTHMBd1LiNDEy71dHMfyxAF17g8Bc9qOxvl7EyFiOAsxdKMHIVKWwU/7Zpyx9rIOvdctXx7dfXkqAAXI6dEnSA3r2JVhTDTUL1wa8NUBQWD@Cpf/RSVJI8EhzLv/EAFE2P/Qi1ndS4LAA).
### Explanation
Consider inputs `'abcdABC123'` and `4`.
```
tt     % Implicitly input string. Duplicate twice
       % STACK: 'abcdABC123', 'abcdABC123', 'abcdABC123'
f      % Find: indices of nonzero elements: gives [1 2 ... n] where n is input length
       % STACK: 'abcdABC123', 'abcdABC123', [1 2 3 4 5 6 7 8 9 10]
i      % Input n
       % STACK: 'abcdABC123', 'abcdABC123', [1 2 3 4 5 6 7 8 9 10], 4
X\     % 1-based modulo
       % STACK: 'abcdABC123', 'abcdABC123', [1 2 3 4 1 2 3 4 1 2 3 4]
qg     % Subtract 1, convert to logical: gives true (1) for 1, false (0) otherwise
       % STACK: 'abcdABC123', 'abcdABC123', [0 1 1 1 0 1 1 1 0 1]
P      % Flip
       % STACK: 'abcdABC123', 'abcdABC123', [1 0 1 1 1 0 1 1 1 0]
)      % Use as logical index into the string
       % STACK: 'abcdABC123', 'acdAC12'
S      % Sort
       % STACK: 'abcdABC123', '12ACacd'
5M     % Push logical index again
       % STACK: 'abcdABC123', '12ACacd', [1 0 1 1 1 0 1 1 1 0]
(      % Write into original string as specified by the index. Implicitly display
       % STACK: 1b2ACBacd3
```
1-based modulo means that `mod([1 2 3 4 5], 3)` gives [`[1 2 3 1 2]`](https://tio.run/nexus/matl#@x8R8/9/tKGCkYKxgomCaSyXMQA) instead of the usual (0-based) [`[1 2 0 1 2]`](https://tio.run/nexus/matl#@x/z/3@0oYKRgrGCiYJpLJcxAA). This is needed here to handle the case `n=1` adequately.
[Answer]
# PHP, 101 bytes
negative string indexes (PHP 7.1) save 21 bytes - and possibly the day:
```
for([,$s,$n]=$argv;a&$c=$s[$i-=1];)$i%$n+1?$a[]=$c:0;for(sort($a);++$i;)echo$i%$n+1?$a[+$k++]:$s[$i];
```
Run with `php -nr '<code>' '<string>' <N>`.
**breakdown**
```
for([,$s,$n]=$argv;     # import command line arguments to $s and $n
    a&$c=$s[$i-=1];)    # loop backward through string
    $i%$n+1?$a[]=$c:0;      # if index is not n-th, copy character to array
for(sort($a);           # sort array
    ++$i;)              # loop forward through string:
    echo$i%$n+1             # if index is not n-th
        ?$a[+$k++]              # print character from array
        :$s[$i]                 # else print character from string
    ;
```
[Answer]
# Python 2, 191 bytes
Yeah, I'm sure this is a terrible solution.
```
n,s=input()
s=s[::-1]
R=range(len(s)/n+1)
J=''.join
k=s[::n]
t=J(sorted(J(s[i*n+1:i*n+n]for i in R)))
n-=1
print J(j[::-1]for i in zip(k,[t[::-1][i*n:i*n+n][::-1]for i in R])for j in i)[::-1]
```
[**Try it online**](https://tio.run/nexus/python2#XY49D4IwEIb3@xXEhVZBU3Bq0gGICyMrYeBLc2AO0tbE@OeRinFwuTy5e/Leu1BgFNL8sIyDUaaUMhQVFErXdOvZvSdm@IkOgkOufP84TEgwfjyqwKqcmUnbvmMrlLhfRekmVddJe@gheQXnHChUAmaNZL2cDduTn/HCmY1Babe1S/lm/HlFxR0PjpFvx2U5B7u6abskzUQU7wAuz7lv10YSQDRRkqV128Vv)
I'm not going to bother explaining it. It was alright until I realized that it needs to be indexed from the end. Now it's a monster. At this point, I'm just glad it works.
[Answer]
# [Octave](https://www.gnu.org/software/octave/), ~~65~~ 54 bytes
```
function s=f(s,n)
l=~~s;l(end:-n:1)=0;s(l)=sort(s(l));
```
[Try it online!](https://tio.run/nexus/octave#PY9ZU8IwHMTf@yn@iiWtVqAVRqVWLeKBcnhUPB6U0CYQCQk2KQ4efHUEH3zb@e3szu6CZiLWTApQAbWUI2yDB/O58rlFRFLdFlXXDkq@srgdKJlqa6Vsf7E0wYQ2iYlSOJ0BlSlEjY4DQmpgFPSQwH81U6C0TEkCTACGXmHcA8o4ASshFGdc/8VbYdQMa8VOrPGU2IZhQkSUhhgroqoGtZDAdIBHCrtexcutmznkuPaK54thl/JJHTmeW/4jg93mfgSnLwIaX4cHuRGDx7u3tWzIYRZAe@v7I/x5mp@P8/IIofj5uu7VsHN7dqlM6FbuCw@@SwBKr5@tYrLRv@gdT6/kDZR3Ou@bJ8jZs5fH6zLrL/cjBFoCUTGeEOBMkxRzQIXFLw "Octave ‚Äì TIO Nexus")
Uses logical indexing to make an array of 'fixed' and 'sorted' characters. Explanation:
```
function s=f(s,n) % Create a function, taking a string `s` and the number `n`; the output is also named `s`.
l=~~s;             % Create logical array with the same size of the input string 
                  %    [equivalent to much more verbose true(size(s))].
l(end:-n:1)=0;    % Set the 'fixed' character positions. MATLAB/Octave automatically produces
                  %    the correct result even if n is larger than the string length.
s(l)=sort(s(l)) % Select the elements from `s` where `l` is true. Sort, and store in the corresponding positions in `s`.
```
The way I created `l` requires that `s` is nonzero, which I think is a reasonable requirement, as many languages use `\0` as an end-of-string delimiter.
[Answer]
## JavaScript (ES6), ~~100~~ 93 bytes
Takes input in currying syntax `(s)(n)`.
```
s=>n=>s.replace(/./g,(c,i)=>(F=_=>(s.length-++i)%n)()?[...s].filter(F,i=0).sort()[j++]:c,j=0)
```
### Formatted and commented
```
s => n => s.replace(        // given a string s and an integer n
  /./g,                     // for each character c of s
  (c, i) => (               // at position i:
    F = _ =>                //   F = function that tests whether the
      (s.length - ++i) % n  //       character at position i is non-static
  )()                       //   call F() on the current position
  ?                         //   if the current character is non-static:
    [...s].filter(F, i = 0) //     get the list of non-static characters
      F, i = 0              //     by filtering all characters in s with F()
    )                       //
    .sort()[j++]            //     sort them and pick the next occurrence
  :                         //   else:
    c,                      //     let c unchanged
  j = 0                     //   initialize j = non-static character pointer
)                           //
```
### Test cases
```
let f =
s=>n=>s.replace(/./g,(c,i)=>(F=_=>(s.length-++i)%n)()?[...s].filter(F,i=0).sort()[j++]:c,j=0)
console.log(f("abcdABC123")(4))
console.log(f('nafgaksa1252#"%#')(1))
console.log(f('&/lpfAVD')(214))
console.log(f("g7L9T E^n I{><#ki XSj!uhl y= N+|wA}Y~Gm&o?'cZPD2Ba,RFJs% V5U.W;1e  0_zM/d$bH`@vKoQ 43Oq*C")(8))
```
[Answer]
# [Perl 5](https://www.perl.org/) `-lF`, 78+3 = 81 bytes
```
$i=<>;map{(@F-++$c)%$i&&((push@b,$_),$_='')}@F;say map/./?$_:(sort@b)[$g++],@F
```
[Try it online!](https://tio.run/##K0gtyjH9/18l09bGzjo3saBaw8FNV1tbJVlTVSVTTU1Do6C0OMMhSUclXhOIbdXVNWsd3KyLEysVgIr19fTtVeKtNIrzi0ockjSjVdK1tWN1HNz@/7e0MDczNTE2MjTgMvqXX1CSmZ9X/F/X11TPwNDgv26OGwA "Perl 5 ‚Äì Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~14~~ 13 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
F·π¢·πÅ
·πös·πö¬µ·∏¢‚Ç¨≈º@√á
```
Full program that prints the string to STD out\*.
**[Try it online!](https://tio.run/nexus/jelly#@@/2cOeihzsbuR7unFUMxIe2Ptyx6FHTmqN7HA63////XykxKTnF0cnZ0MhY6b8JAA)**
### How?
```
·πös·πö¬µ·∏¢‚Ç¨≈º@√á - Main link: string s, non-negative number n
·πö         - reverse s
 s        - split into chunks of size n
  ·πö       - reverse the resulting list
   ¬µ      - monadic chain separation (call that list x)
    ·∏¢‚Ç¨    - head ‚Ç¨ach - yield a list of the first entries of each of x and modify x
        √á - call the last link (1) as a monad - get the sorted and re-split list
      ≈º@  - zip together (with reversed @rguments)
F·π¢·πÅ - link 1, sort and reshape like self: list of lists
F   - flatten into a single list
 ·π¢  - sort
  ·πÅ - mould the result like the input
```
*~~I can't help but think~~ there is a way to use the fact that `·∏¢` modifies its input*
\* for a function one would want to flatten the output into a single list with `F`.  
For example an input of `"abcdABC123"`, `4` yields:  
`[[['1'],['b']],[['2','A','C'],['B']],[['a','c',',d'],['3']]]`  
rather than:  
`['1','b','2','A','C','B','a','c',',d','3']`
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 100 bytes
```
n=>g=x=>x.some((c,i)=>(i-(L=x.length-1))%n&&x.some((d,j)=>(j-L)%n&&i<j&c>d&&[x[i]=d,x[j]=c]))?g(x):x
```
[Attempt This Online!](https://ato.pxeger.com/run?1=ZY9ZUsJAFEX_XUUbpNOtSWMClKh0kEGccFYcUlE7IwmhWyugcdyIP5Sli3IbrkAU_dGvV_XOqfvefX7lwvWGL036Nuj7aund5dQIaEqNlCSi5yHkKCGmBgpV1KIpiT0e9DuqhnGWQ_jruEr05URq63sdliPoGC6EZmqGFnWV1Iws6lgYVwKU4oX059aHTxk1bGo0kY2RSQhhFiaRCDmSZTzhCJ6I2COxCJCPJGY7brVW1_S8hFEB_-UyZ37AugnT9KKekbIZGSPtvwVz8aVfbTdGVNf-p0jBXGv-ACyfcbB2b5Qz3RAc70eTg04MbinYmnm4qT6ePK30oKjIzulOQ68xZa-5nmRBu3hIjhY1D4DZ87vNnDtlr14sXW-IXVDIb19N10dPlzAeNx8Ox_MT)
Use no `sort`
[Answer]
# [Perl 5](https://www.perl.org/), 94 bytes
88 bytes of code + `-F -pl` flags.
```
$_=join"",(map{(--$i%$n?"":$F[$#F-$i--]),$_}sort grep$i++%$n,reverse@F),chop if($n=<>)>1
```
[Try it online!](https://tio.run/nexus/perl5#DcrbUoJAGADg@32KX1gMgk13hdQS1FQ6n8tOU0i2IIqwQdmU2auTl9/MJ5cEz2IgLhARF9izp2mUSJKhzn2xVAnBkYKTtiTtYPcJy@7ahDxrBvZWeZp9QJhxgSNdXycj4wue5bzjasZ4kgqIAhUndsvRHFoUiR@E/iz3KbOYLCkyoqjZqG9bZo3RKmKoXIlF0B32EaMmCusnzRsYvCRwuHRa8iyC@@tp6XMSw7cNZ/rvV3f18Lc/L6ftjfHjRZ/t@caVe5QrMLRut@52KQeoej@nlTf8ejDqLI7TSzBr5@@bPdT4Bw "Perl 5 ‚Äì TIO Nexus")
It's quite too long in my opinion, but already not that ugly... I'm still trying to golf it further anyway.
[Answer]
# [Python](https://www.python.org/) + [NumPy](http://www.numpy.org/), ~~115~~ 114 bytes
```
from numpy import *
def f(x,n):l=len(x);x=array(x);m=[1<2]*l;m[-1::-n]=[1>2]*len(m[0::n]);x[m]=sort(x[m]);return x
```
Takes a regular Python list as input (wasn't sure whether taking an array would be considered kosher); returns a NumPy array containing the result.
Works by masking out the relevant indices and sorting the rest.
[Answer]
## Python 2, ~~119~~ 113 bytes
```
n,l=input()
i=range(len(l))
print"".join(sorted(l[~a]for a in i if a%n)[-a+a/n]if a%n else l[~a]for a in i)[::-1]
```
Builds a list of all characters to be sorted, sorts them and merges them for printing, while avoiding some of the reversing via negative indexing.
[Answer]
# [Burlesque](https://github.com/FMNSSun/Burlesque), 36 bytes
```
pe<-jJ-.hdcoJ)-]j)[-++<>#acoz[\[\[<-
```
[Try it online!](https://tio.run/##SyotykktLixN/f@/INVGN8tLVy8jJTnfS1M3NkszWldb28ZOOTE5vyo6BghtdP//N1KytDA3MzUxNjI0UAIA "Burlesque ‚Äì Try It Online")
Takes input as `N "String"`
```
pe       # Parse and push
<-       # Reverse the string
j        # Put N at the top of the stack
J-.hd    # Store N-1 for later
co       # Split string into chunks of N
J)-]     # Duplicate and take the heads
j)[-     # Take the tails of the other duplicate
++       # Reduce all the "useless" chars to string
<>       # Reverse sort
#aco     # Split into chunks of N-1
z[       # Zip the two lists
\[\[     # Flatten to string
<-       # Reverse the string
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 53 bytes
```
{(my@a=$^a.comb)[grep (@a-*-1)%$^n,^@a].=sort;[~] @a}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwv1ojt9Ih0VYlLlEvOT83STM6vSi1QEHDIVFXS9dQU1UlLk8nziExVs@2OL@oxDq6LlbBIbH2f3FipUKaglJiUnKKo5OzoZGxko6CyX8A "Perl 6 ‚Äì Try It Online")
It feels like there should be a shorter way of doing this
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 14 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
DƒÅR<I√ñ‚â†¬©√è{¬Æ∆∂<«ù
```
I/O of the string as a list of characters.
[Try it online](https://tio.run/##yy9OTMpM/f/f5UhjkI3n4WmPOhccWnm4vzr40Lpj22yOz/3/P1opUUlHKQmIk4E4BYgdgdgJiJ2B2BCIjYDYWCmWywQA) or [verify all test cases](https://tio.run/##yy9OTMpM/W/qpuSZV1BaUmyloGTv6WIfrKSQmJcCZofqcCn5l5YAJUFy/12ONAbZRBye9qhzwaGVh/urD607ts3m@Nz/Xjr/E5OSUxydnA2NjLlMuCwtzM1MTYyNDA24jLjyEtPSE7OLEw2NTI2UlVSVuQy51PRzCtIcw1y4jAxNuNLNfSxDFFzj8hQ8q@1slLMzFSKCsxRLM3IUKm0V/LRryh1rI@vcc9Xy7dWTowJcjJwSdYLcvIpVFcJMQ/XCrQ1TFRQM4qt89VNUkjwSHMq88wMVTIz9C7WcuSwA) (feel free to remove the `S` and `J` in the test suite to see the actual I/O with character lists).
And I agree with [*@mbomb007*'s comment](https://codegolf.stackexchange.com/questions/112935/sort-useless-characters#comment275399_112963), although it's still pretty short this way. :)
**Explanation:**
```
                #  Example inputs: s=["a","b","c","d","A","B","C","1","2","3"] and n=4
D               # Duplicate the (implicit) character-list input
                #  STACK: [["a","b","c","d","A","B","C","1","2","3"],
                #          ["a","b","c","d","A","B","C","1","2","3"]]
 ƒÅ              # Push a list in the range [1,list-length] (without popping the list)
                #  STACK: [s, s, [1,2,3,4,5,6,7,8,9,10]]
  R             # Reverse it to range [length,1]
                #  STACK: [s, s, [10,9,8,7,6,5,4,3,2,1]]
   <            # Decrease each by 1 to range (length,0]
                #  STACK: [s, s, [9,8,7,6,5,4,3,2,1,0]]
    I√ñ          # Check for each if it's divisible by the integer-input
                #  STACK: [s, s, [0,1,0,0,0,1,0,0,0,1]]
      ‚â†         # And invert those truthy/falsey values
                #  STACK: [s, s, [1,0,1,1,1,0,1,1,1,0]]
       ¬©        # Store this list of truthy/falsey values in variable `¬Æ`
        √è       # Only keep the characters in the list at the truthy indices
                #  STACK: [s, ["a","c","d","A","C","1","2"]]
         {      # Sort those
                #  STACK: [s, ["1","2","A","C","a","c","d"]]
          ¬Æ     # Push the truthy/falsey list again from variable `¬Æ`
                #  STACK: [s, ["1","2","A","C","a","c","d"], [1,0,1,1,1,0,1,1,1,0]]
           ∆∂    # Multiply each by their 1-based index
                #  STACK: [s, ["1","2","A","C","a","c","d"], [1,0,3,4,5,0,7,8,9,0]]
            <   # Decrease everything by 1 to make it 0-based indexing
                #  STACK: [s, ["1","2","A","C","a","c","d"], [0,-1,2,3,4,-1,6,7,8,-1]]
             «ù  # Insert the sorted characters at those indices in the list
                # (NOTE: Unlike almost all other 05AB1E builtins that use indices, this
                # insert builtin ignores negative and too large indices instead of using
                # modular indexing, so the -1 are conveniently ignored here.)
                #  STACK: [["1","b","A","C","a","B","d","1","2","3"]]
                # (after which this list is output implicitly as result)
```
[Answer]
# [Uiua](https://uiua.org), 16 [bytes](https://codegolf.stackexchange.com/a/265917/97916)
```
‚çú‚ñΩ(‚äè‚çè.)¬¨‚áå=0‚óø:‚á°‚ßª,
```
[Try it!](https://uiua.org/pad?src=0_5_1__ZiDihpAg4o2c4pa9KOKKj-KNjy4pwqzih4w9MOKXvzrih6Hip7ssCgpmIDEgIm5hZmdha3NhMTI1MiNcIiUjIgpmIDIxNCAiJi9scGZBVkQiCmYgOCAiZzdMOVQgRV5uIEl7Pjwja2kgWFNqIXVobCB5PSBOK3x3QX1ZfkdtJm8_J2NaUEQyQmEsUkZKcyUgVjVVLlc7MWUgIDBfek0vZCRiSGBAdktvUSA0M09xKkMiCg==)
```
‚çú‚ñΩ(‚äè‚çè.)¬¨‚áå=0‚óø:‚á°‚ßª,
             ‚á°‚ßª,  # range of length
           ‚óø:     # modulo input
         =0       # where is it zero?
        ‚áå         # reverse
       ¬¨          # not
‚çú‚ñΩ(‚äè‚çè.)           # under-keep-sort (sort input where mask is 1)
```
[Answer]
# [J](http://jsoftware.com/), 28 bytes
```
]/:~@#~`(I.@])`[}0<(|i.@-@#)
```
[Try it online!](https://tio.run/##Zc7XjoJgEAXge59iFOW3gqDGFRvN3huWjQqi2FA0Ro2NV2dXt9w4yVzNd3JmZTkIpEGSAQR@CALzvQEChGY5aw1JxmQxU3YXCHbokT8fwYT7viTYAIt5LI@tyhPwTkzm39hm6sIARE1oTuAVdRpCEGAgDBogZaJOOV6g6BD6VTjJSZq@E1@Gpl4KJ/Wdxknin9kq2lxZHxSKjtCYw4W9LPWUb5ffxBx@Zgt2zOnCEVp6fX6CDFI6HQpHorH4OZFMpVlONDLZXL5QLPHlSrVWbzSh1e5I3V5/NhiN5ee3i9V6sz8cjdPlers/TOHV/fHsnkfLsTZkRlso3FIJbL2EXmtlPy50uCSh6rufuUffzG1wI42QOqiLNK/4m9niwQVSpEN049QMIDi@Vsipc5KX2VPJaEA4VNt7BWR9AQ "J ‚Äì Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 11 bytes
```
·∫è·πò~·∏ûF·πò‚ÅΩs?‚àá¬¢
```
[Try it Online!](https://vyxal.pythonanywhere.com/?v=2&c=1#WyIiLCIiLCLhuo/huZh+4bieRuG5mOKBvXM/4oiHwqIiLCIiLCJhYmNkQUJDMTIzXG40Il0=)
Outputs as a list of characters
## Explained
```
·∫è·πò~·∏ûF·πò‚ÅΩs?‚àá¬¢¬≠‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å°‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å§‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å¢‚Äã‚Äé‚Å™‚Å™‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å£‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å£‚Å™‚Äè‚Å†‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å¢‚Å§‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å¢‚Å§‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å¢‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Å°‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å°‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå‚Å£‚Å¢‚Äã‚Äé‚Äé‚Å™‚Å°‚Å™‚Å†‚Å™‚Å£‚Å£‚Å™‚Äè‚Äè‚Äã‚Å°‚Å†‚Å°‚Äå¬≠
  ~·∏û         # ‚Äé‚Å°Every nth item of
·∫è·πò           # ‚Äé‚Å¢The range [len(string), 0]
  ~          # ‚Äé‚Å£without popping anything
    F        # ‚Äé‚Å§Remove each item in that "every nth item" list from the range
     ·πò       # ‚Äé‚Å¢‚Å°Reverse that so that the indices are in ascending order
          ¬¢  # ‚Äé‚Å¢‚Å¢Apply
      ‚ÅΩs     # ‚Äé‚Å¢‚Å£A function that sorts its argument
         ‚àá   # ‚Äé‚Å¢‚Å§to the items at indices in
        ?    # ‚Äé‚Å£‚Å°the string
          ¬¢  # ‚Äé‚Å£‚Å¢and insert the items in the result back at those indices
üíé
```
Created with the help of [Luminespire](https://vyxal.github.io/Luminespire).
[Answer]
# Ruby, 64 bytes
Uses regex to grab all irrelevant characters, both for replacement and for sorting.
```
->i,s,j=-1{s.gsub(r=/.(?!(?=.{#{i}})*$)/){s.scan(r).sort[j+=1]}}
```
[Try it online](https://repl.it/GgEN)
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), ~~111~~ 109 bytes
```
lambda n,s:(l:=len(s),r:=sorted(s[~i]for i in range(l)if i%n),[r.insert(i,s[i])for i in range(~-l%n,l,n)])[1]
```
[Try it online!](https://tio.run/##bc3ZUsIwGEDhe5/iFyxNNAJpQRatyuK@b7jUqoG2EAhpTaqOG69e8Zbh/ptz4s9kEEm7Gqs0BAceU8HGXZ@BJLqORN0RgUQaE1V3dKSSwEfanXAvjBRw4BIUk/0ACcxD4IbExFV5LnWgEsSJdrmHZ@RkVRiSCCKxh13qpbHiMkGmmR9GXKIQlQiYrNvzG80WtWwTY7wwS6wpqVUra@WSbdHiXEKnRLKwz0aaUatsZTNGdn6L/g9zBRGHjU57LqkSyPQrx7Vr2HmScPC9uZEdcbi7Gi6@DQR8OnC68vPR@L2f7I1z0ZbZezhvW01GLncPtQGd8k3@dp0GAMXnr5OCv9Tdf9l@P4ouoGSfvS63MtNj@gc "Python 3.8 (pre-release) ‚Äì Try It Online")
]