Sort useless characters This challenge is inspired by this 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 nth 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   &lt;- Input string. (n=4)
_b___B___3   &lt;- These will not be sorted (every 4th starting from the end)
1_2AC_acd_   &lt;- The remaining characters, sorted
1b2ACBacd3   &lt;- The final string (the output)


Another example:

9876543210   &lt;- Input string (n=2)
_8_6_4_2_0   &lt;- These will not be sorted
1_3_5_7_9_   &lt;- The remaining characters, sorted
1836547290   &lt;- 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. 
&amp;/lpfAVD
&amp;/AVflpD  

n=8
g7L9T E^n I{&gt;&lt;#ki XSj!uhl y= N+|wA}Y~Gm&amp;o?'cZPD2Ba,RFJs% V5U.W;1e  0_zM/d$bH`@vKoQ 43Oq*C
g       n !#$%&amp;'i*+,./01l234579;w&lt;=&gt;?@ADoEFGHIJKBLMNOPQR STUVWXYeZ^_`abcdhjkmqsuovyz{|}~C
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! Or verify all test cases.
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] instead of the usual (0-based) [1 2 0 1 2]. This is needed here to handle the case n=1 adequately.