text:
Rubik-sorting a matrix (a.k.a. the torus puzzle)
The idea for this code-challenge is simple: given a matrix of integers, let's sort it by applying Rubik-style movements. This means that you can select a single row or column and rotate its elements in any direction:
[1, 3, 2, 4]  => [3, 2, 4, 1] (rotate left for rows/up for columns)
[1, 3, 2, 4]  => [4, 1, 3, 2] (rotate right for rows/down for columns)

So, given a matrix of integers of any dimension, sort its elements applying only these Rubik-style transformations. A matrix
$$ \begin{bmatrix}
 a_{11} & a_{12} & a_{13} & a_{14} \\
 a_{21} & a_{22} & a_{23} & a_{24} \\
 a_{31} & a_{32} & a_{33} & a_{34}
\end{bmatrix} $$
will be considered sorted iff its elements comply with the following restriction:
$$ a_{11} \leq a_{12} \leq a_{13} \leq a_{14} \leq a_{21} \leq a_{22} \leq a_{23} \leq a_{24} \leq a_{31} \leq a_{32} \leq a_{33} \leq a_{34} $$
I/O

Input will be a matrix of positive integers with no repeated values.
Output will be the movements needed to sort it. As this is not a code golf challenge and you don't need to worry about its length, the proposed format for every movement is #[UDLR] where # is the number of the row or column to move (0-indexed) and [UDLR] is a single character in that range that specifies if the movement is Up/Down (for columns) or Left/Right (for rows). So 1U would mean "move the 1-th column upwards" but 1R would be "move the 1-th row rightwards". Movements will be comma-separated, so a solution will be expressed like this: 1R,1U,0L,2D.

Scoring
Trying to sort a matrix this way can be costly as there are a lot of possible combinations of moves, and there are also a lot of possible lists of moves that can sort it, so the goal is to write some code that sorts the N*N matrices below. The score will be the greatest size N that you can solve in a reasonable amount of time1 without errors (the greater the size of the matrix solved, the better). In case of a tie, the tie-breaker will be the number of movements in your found path (the shorter the path, the better).
Example: if a user A finds a solution for N=5 and B finds a solution for N=6, B wins regardless of the length of both paths. If they both find solutions for N=6 but the solution found by A has 50 steps and B's solution has 60 steps, A wins.
Explanations on how your code works are highly encouraged and please post the solutions found so we can test them. You can use Pastebin or similar tools if the solutions are too big. Also, an estimation of the time spent by your code to find your solutions will be appreciated.
Test cases
The following matrices (Pastebin link for a more copy-pasteable version) have been created starting from already sorted matrices by scrambling them with 10K random, Rubik-style movements:

\begin{bmatrix}
 8 & 5 & 6 \\
11 & 10 & 1 \\
3 & 15 & 13 \\
\end{bmatrix} \begin{bmatrix}
21 & 10 & 12 & 16   \\
17 & 6 & 22 & 14   \\
8 & 5 & 19 & 26   \\
13 & 24 & 3 & 1   \\
\end{bmatrix} \begin{bmatrix}
1 & 13 & 8 & 16 & 5   \\
9 & 40 & 21 & 26 & 22   \\
11 & 24 & 14 & 39 & 28   \\
32 & 19 & 37 & 3 & 10   \\
30 & 17 & 36 & 7 & 34   \\
\end{bmatrix} \begin{bmatrix}
34 & 21 & 40 & 22 & 35 & 41   \\
18 & 33 & 31 & 30 & 12 & 43   \\
19 & 11 & 39 & 24 & 28 & 23   \\
44 & 1 & 36 & 5 & 38 & 45   \\
14 & 17 & 9 & 16 & 13 & 26   \\
8 & 3 & 47 & 6 & 25 & 4   \\
\end{bmatrix} \begin{bmatrix}
20 & 36 & 17 & 1 & 15 & 50 & 18   \\
72 & 67 & 34 & 10 & 32 & 3 & 55   \\
42 & 43 & 9 & 6 & 30 & 61 & 39   \\
28 & 41 & 54 & 27 & 23 & 5 & 70   \\
48 & 13 & 25 & 12 & 46 & 58 & 63   \\
52 & 37 & 8 & 45 & 33 & 14 & 68   \\
59 & 65 & 56 & 73 & 60 & 64 & 22   \\
\end{bmatrix} \begin{bmatrix}
85 & 56 & 52 & 75 & 89 & 44 & 41 & 68   \\
27 & 15 & 87 & 91 & 32 & 37 & 39 & 73   \\
6 & 7 & 64 & 19 & 99 & 78 & 46 & 16   \\
42 & 21 & 63 & 100 & 4 & 1 & 72 & 13   \\
11 & 97 & 30 & 93 & 28 & 40 & 3 & 36   \\
50 & 70 & 25 & 80 & 58 & 9 & 60 & 84   \\
54 & 96 & 17 & 29 & 43 & 34 & 23 & 35   \\
77 & 61 & 82 & 48 & 2 & 94 & 38 & 66   \\
\end{bmatrix} \begin{bmatrix}
56 & 79 & 90 & 61 & 71 & 122 & 110 & 31 & 55   \\
11 & 44 & 28 & 4 & 85 & 1 & 30 & 6 & 18   \\
84 & 43 & 38 & 66 & 113 & 24 & 96 & 20 & 102   \\
75 & 68 & 5 & 88 & 80 & 98 & 35 & 100 & 77   \\
13 & 21 & 64 & 108 & 10 & 60 & 114 & 40 & 23   \\
47 & 2 & 73 & 106 & 82 & 32 & 120 & 26 & 36   \\
53 & 93 & 69 & 104 & 54 & 19 & 111 & 117 & 62   \\
17 & 27 & 8 & 87 & 33 & 49 & 15 & 58 & 116   \\
95 & 112 & 57 & 118 & 91 & 51 & 42 & 65 & 45   \\
\end{bmatrix}

Plaintext Test Cases:
[[8, 5, 6], [11, 10, 1], [3, 15, 13]]

[[21, 10, 12, 16], [17, 6, 22, 14], [8, 5, 19, 26], [13, 24, 3, 1]]

[[1, 13, 8, 16, 5], [9, 40, 21, 26, 22], [11, 24, 14, 39, 28], [32, 19, 37, 3, 10], [30, 17, 36, 7, 34]]

[[34, 21, 40, 22, 35, 41], [18, 33, 31, 30, 12, 43], [19, 11, 39, 24, 28, 23], [44, 1, 36, 5, 38, 45], [14, 17, 9, 16, 13, 26], [8, 3, 47, 6, 25, 4]]

[[20, 36, 17, 1, 15, 50, 18], [72, 67, 34, 10, 32, 3, 55], [42, 43, 9, 6, 30, 61, 39], [28, 41, 54, 27, 23, 5, 70], [48, 13, 25, 12, 46, 58, 63], [52, 37, 8, 45, 33, 14, 68], [59, 65, 56, 73, 60, 64, 22]]

[[85, 56, 52, 75, 89, 44, 41, 68], [27, 15, 87, 91, 32, 37, 39, 73], [6, 7, 64, 19, 99, 78, 46, 16], [42, 21, 63, 100, 4, 1, 72, 13], [11, 97, 30, 93, 28, 40, 3, 36], [50, 70, 25, 80, 58, 9, 60, 84], [54, 96, 17, 29, 43, 34, 23, 35], [77, 61, 82, 48, 2, 94, 38, 66]]

[[56, 79, 90, 61, 71, 122, 110, 31, 55], [11, 44, 28, 4, 85, 1, 30, 6, 18], [84, 43, 38, 66, 113, 24, 96, 20, 102], [75, 68, 5, 88, 80, 98, 35, 100, 77], [13, 21, 64, 108, 10, 60, 114, 40, 23], [47, 2, 73, 106, 82, 32, 120, 26, 36], [53, 93, 69, 104, 54, 19, 111, 117, 62], [17, 27, 8, 87, 33, 49, 15, 58, 116], [95, 112, 57, 118, 91, 51, 42, 65, 45]]

Please ask for more if you solve them all. :-) And many thanks to the people who helped me refine this challenge while in the sandbox.

1 A reasonable amount of time: any amount of time that doesn't undermine our patience while testing your solution. Note that TIO only runs code for 60 seconds, any amount of time over that limit will make us test the code in our machines. Example: my rather inefficient algorithm takes a few milliseconds to solve matrices of order 3x3 and 4x4, but I have just tested it with a 5x5 matrix and it took 317 seconds to solve it (in over 5 million movements, very funny if we consider that the matrix to solve was scrambled only 10K times). I tried to reduce the number of movements to less than 10K but I surrendered after 30 minutes executing the code.

Nice challenge! However, I have a few requests/questions: 1) Could you provide the test cases in a more copy-paste friendly format? (such as pastebin) 2) Could you provide a more precise definition of the time limit order? 3) Is the matrix guaranteed to be square? (The test cases suggest so, but the definition does not.)

@Arnauld 1) I'm on it. 2) I didn't want to establish a time limit, and nobody suggested any limit while the challenge was in the sandbox. If you need one, would you consider 30 minutes a reasonable limit? 3) Yes, the test matrices are the ones shown, and they will all be square if more are needed.

There exists an (relatively easy to implement) O(input size) algorithm to this challenge, so it's not as interesting as it may look at first.

@user202729 What would the input-size be in your O(input size) then? For a 5x5 matrix it would O(25)? That seems to be extremely fast, so I would be very interested to see that algorithm or implementation of yours. EDIT: You do realize we input the 'scrambled' matrix and output the movements, right? Not the other way around.

@kevin Yes that's correct. / Yes, I know.

I think, it's something like this algorithm

@KirillL. I've got the same idea with the triangular movement. The rest is just details.

Nim
import algorithm, math, sequtils, strutils

let l = split(stdin.readLine())
var m = map(l, parseInt)
let n = int(sqrt(float(len(m))))
let o = sorted(m, system.cmp[int])

proc rotations(P, Q: int): tuple[D, L, R, U: string, P, Q: int]=
  result = (D: "D", L: "L", R: "R", U: "U", P: P, Q: Q)
  if P > n - P:
    result.D = "U"
    result.U = "D"
    result.P = n - P
  if Q > n - Q:
    result.L = "R"
    result.R = "L"
    result.Q = n - Q

proc triangle(r: int): string=
  let p = r div n
  let q = r mod n
  let i = find(m, o[r])
  let s = i div n
  let t = i mod n
  var u = s
  var v = q
  if s == p and t == q:
    return ""
  var patt = 0
  if p == s:
    u = s + 1
    patt = 4
  elif q == t:
    if q == n - 1:
      v = t - 1
      patt = 8
    else:
      u = p
      v = t + 1
      patt = 3
  elif t > q:
    patt = 2
  else:
    patt = 7
  var Q = abs(max([q, t, v]) - min([q, t, v]))
  var P = abs(max([p, s, u]) - min([p, s, u]))
  let x = p*n + q
  let y = s*n + t
  let z = u*n + v
  let w = m[x]
  m[x] = m[y]
  m[y] = m[z]
  m[z] = w
  let R = rotations(P, Q)

  result = case patt:
    of 2:
      repeat("$#$#," % [$v, R.D], R.P) &
        repeat("$#$#," % [$u, R.L], R.Q) &
        repeat("$#$#," % [$v, R.U], R.P) &
        repeat("$#$#," % [$u, R.R], R.Q)
    of 3:
      repeat("$#$#," % [$q, R.U], R.P) &
        repeat("$#$#," % [$p, R.L], R.Q) &
        repeat("$#$#," % [$q, R.D], R.P) &
        repeat("$#$#," % [$p, R.R], R.Q)
    of 4:
      repeat("$#$#," % [$p, R.L], R.Q) &
        repeat("$#$#," % [$q, R.U], R.P) &
        repeat("$#$#," % [$p, R.R], R.Q) &
        repeat("$#$#," % [$q, R.D], R.P)
    of 7:
      repeat("$#$#," % [$v, R.D], R.P) &
        repeat("$#$#," % [$u, R.R], R.Q) &
        repeat("$#$#," % [$v, R.U], R.P) &
        repeat("$#$#," % [$u, R.L], R.Q)
    of 8:
      repeat("$#$#," % [$s, R.R], R.Q) &
        repeat("$#$#," % [$t, R.D], R.P) &
        repeat("$#$#," % [$s, R.L], R.Q) &
        repeat("$#$#," % [$t, R.U], R.P)
    else: ""

proc Tw(p, t, P, Q: int): string =
  let S = P + Q
  result = "$#D,$#$#U,$#$#D,$#$#U," % [
    $t, if P > n - P: repeat("$#L," % $p, n - P) else: repeat("$#R," % $p, P),
    $t, if S > n - S: repeat("$#R," % $p, n - S) else: repeat("$#L," % $p, S),
    $t, if Q > n - Q: repeat("$#L," % $p, n - Q) else: repeat("$#R," % $p, Q),
    $t]

proc line(r: int): string=
  let p = n - 1
  let q = r mod n
  let i = find(m, o[r])
  var t = i mod n
  if t == q:
    return ""
  let j = t == n - 1
  var P = t - q
  let x = p*n + q
  let y = x + P
  let z = y + (if j: -1 else: 1)
  let w = m[x]
  m[x] = m[y]
  m[y] = m[z]
  m[z] = w
  if j:
    let R = rotations(1, P)
    result = "$#D,$#$#U,$#$#R,$#D,$#L,$#U," % [
      $t, repeat("$#$#," % [$p, R.R], R.Q),
      $t, repeat("$#$#," % [$p, R.L], R.Q),
      $p, $t, $p, $t]
  else:
    result = Tw(p, t, P, 1)

proc swap: string=
  result = ""
  if m[^1] != o[^1]:
    m = o
    for i in 0..(n div 2-1):
      result &= Tw(n - 1, n - 2*i - 1, 1, 1)
    result &= "$#R," % $(n - 1)

var moves = ""
for r in 0..(n^2 - n - 1):
  moves &= triangle(r)
if n == 2 and m[^1] != o[^1]:
  m = o
  moves &= "1R"
else:
  for r in (n^2 - n)..(n^2 - 3):
    moves &= line(r)
  if n mod 2 == 0:
    moves &= swap()
  if len(moves) > 0:
    moves = moves[0..^2]

echo moves

Try it online!
A quick attempt to implement the Torus puzzle solution algorithm from an article published in Algorithms 2012, 5, 18-29 that I mentioned in comments.
Accepts the input matrix in flattened form, as a line of space-delimited numbers.
Here also is a validator in Python 2. It takes two lines as input: the original scrambled matrix in the same form as the main code, and the proposed sequence of moves. The output of the validator is the matrix resulting from applying these moves.
Explanation
In the first part of the algorithm, we order all rows except the last one.
We do this by performing series of "triangle rotations" (proc triangle) - the sequences of moves that result in only three cells swapping places, and all the rest staying unchanged. We take each consecutive "working" cell with coordinates \$[p, q]\$, then find the cell \$[s, t]\$ that currently contains the number that should go to \$[p, q]\$, and complete the right triangle by selecting a third point \$[u, v]\$ according to some pattern, as shown in Fig. 4 of the linked article.
In Fig. 2, the authors present 8 possible patterns and the corresponding sequences of moves, but in my code all cases have actually been covered by only 5 patterns, so that no. 1, 5, and 6 are not used.
In the second part, the last row except the two last elements is ordered by performing "three elements rotations" on a line (proc line), which consist of two triangle rotations each (see Fig. 3 of the article).
We select our current working cell \$[p, q]\$ as the left point, cell containing the target value \$[s, t]\$ as the central point, and \$[s, t+1]\$ as the right point. This westbound movement is named \$T_W\$ in the article, and so is my string forming proc for this. If \$t\$ is already the last column, so that \$t+1\$ does not exist, we take \$[s, t-1]\$ as the third point, and modify the action accordingly: two triangle rotations are performed by patterns 7 and 8 (instead of 7 and 1 in the original \$T_W\$ sequence).
Finally, if \$n\$ is odd, the remaining two elements must be already in place, as we are guaranteed that a solution exists.
If \$n\$ is even, and the two remaining elements are not in place, then according to Lemma 1 (page 22), they can be swapped by a series of \$T_W\$ moves, followed by one shift east (\$=R\$). Since the provided example swaps the first two entries, and we need to swap the last two, our proc swap performs \$T_W\$ moves in reverse order.
In the edge case of \$n = 2\$ we don't need all these complex procedures at all - if the last row elements are not in place after part 1, a single \$1R\$ move is sufficient to make the matrix fully ordered.
Update: Added new proc rotations that reverses the direction of moves if that would result in less steps.

Impressive! I'll create some more test cases then. Meanwhile, I'm sure this solution can be optimized, as there are chunks like 7L,7L,7L,7L,7D,7D,7D,7D than can be reduced and 8R,8R,8R,8R,8R,8R,8R than can be converted to 8L,8L for a 9x9 matrix.

I've tried your algorithm with a 100x100 matrix and it solves it in less than 4 seconds. I really didn't expect this problem to have a linear-time solution. I'll try to write better challenges in the future!

Maybe it would have been better to pose this challenge with a single, fixed matrix as the only test case, and set the winning criterion to be just the size of the found path to solve it, had I known before that this problem had a O(n^2) solution. Would you consider porting this answer to a new question with such winning criterion?

@Charlie While I'll still try to refine the current solution a bit, I have really no idea, how to tackle the overall path optimization problem...

Python 2, size 100 in <30 seconds on TIO
import random
def f(a):
 d = len(a)
 r = []
 def V(j, b = -1):
  b %= d
  if d - b < b:
   for k in range(d - b):
    if r and r[-1] == "U%d" % j:r.pop()
    else:r.append("D%d" % j)
    b = a[-1][j]
    for i in range(len(a) - 1):
     a[-1 - i][j] = a[-2 - i][j]
    a[0][j] = b
  else:
   for k in range(b):
    if r and r[-1] == "D%d" % j:r.pop()
    else:r.append("U%d" % j)
    b = a[0][j]
    for i in range(len(a) - 1):
     a[i][j] = a[i + 1][j]
    a[-1][j] = b
 def H(i, b = -1):
  b %= d
  if d - b < b:
   for k in range(d - b):
    if r and r[-1] == "L%d" % i:r.pop()
    else:r.append("R%d" % i)
    a[i] = a[i][-1:] + a[i][:-1]
  else:
   for k in range(b):
    if r and r[-1] == "R%d" % i:r.pop()
    else:r.append("L%d" % i)
    a[i] = a[i][1:] + a[i][:1]
 b = sorted(sum(a, []))
 for i in range(d - 1):
  for j in range(d):
   c = b.pop(0)
   e = sum(a, []).index(c)
   if e / d == i:
    if j == 0:H(i, e - j)
    elif j < e % d:
     if i:
      V(e % d, 1)
      H(i, j - e)
      V(e % d)
      H(i, e - j)
     else:
      V(e)
      H(1, e - j)
      V(j, 1)
   else:
    if j == e % d:
     H(e / d)
     e += 1
     if e % d == 0:e -= d
    if i:
     V(j, i - e / d)
    H(e / d, e - j)
    V(j, e / d - i)
 c = [b.index(e) for e in a[-1]]
 c = [sum(c[(i + j) % d] < c[(i + k) % d] for j in range(d) for k in range(j)) % 2 and d * d or sum(abs(c[(i + j) % d] - j) for j in range(d)) for i in range(d)]
 e = min(~c[::-1].index(min(c)), c.index(min(c)), key = abs)
 H(d - 1, e)
 for j in range(d - 2):
  e = a[-1].index(b[j])
  if e > j:
   c = b.index(a[-1][j])
   if c == e:
    if e - j == 1:c = j + 2
    else:c = j + 1
   V(e)
   H(d - 1, j - e)
   V(e, 1)
   H(d - 1, c - j)
   V(e)
   H(d - 1, e - c)
   V(e, 1)
 return r

Try it online! Link includes three small test cases with full move output, plus a silent test of 100x100 to show that the code works (the move output would exceed TIO's limits). Explanation: The code attempts to perform an insertion sort on the array, building it up in ascending order as it goes. For all the rows except the last row, there are a number of cases:

The element is in the correct row, but belongs in column 0. In this case, it is simply rotated until it reaches column 0.
The element is in the correct place. In this case, nothing happens. (This is also true if the element belongs in column 0, it's just that 0 rotations happen in that case.)
The element is in the top row but in the wrong column. In that case, it is rotated down, then horizontally until the element is in the correct column, then rotated up again.
The element is in the correct row but in the wrong column. In that case, it is rotated up, then the row is rotated to its column, then it is rotated down, then the row is rotated back. (Effectively this is a rotation of the next case.)
The element is in the correct column but in the wrong row. In that case, the row is rotated right, to reduce it to the last case.
The element is in the wrong row and the wrong column. In this case, the correct column is rotated to the wrong row (skipped for the top row), that row is then rotated to the correct column, and the column is then rotated back.

The above rotations are performed in whichever direction minimises the number of steps; a size 2 square is always solved using left and up moves, regardless of the description above.
Before the bottom row is completed, it is rotated to minimise the total distance out of place, but also to ensure that the parity of the bottom row is even, as it can't be changed by the final part of the algorithm. If there is more than one rotation with the same minimal distance, the rotation with the smallest number of moves is chosen.
The algorithm for the bottom row relies on a 7-operation sequence which exchanges the elements in three columns. The sequence is applied to each of the remaining numbers of the bottom row in order in turn to bring them to their desired location; if possible the element in that location is moved to its desired location, but if a straight swap is needed the element is simply moved to the nearest available column, hopefully allowing it to be fixed up next time.

Thank you very much for your answer, Neil! But remember, this is not a code golf. Instead of the length of the code you should indicate the greatest size N of the NxN matrix you have solved and the length of the list of movements to solve that matrix.

@Charlie Well, that's 6, but only becuase I've been too lazy to paste in a bigger matrix. Although it's brute force, it scales linearly with area, so it should be capable of large matrices.

Actually, worst case might be quadratic with area.

@Charlie TIO link now solves a random 100x100 matrix.

@Charlie I've now also optimised the output slightly.

@Charlie Now with a bugfix, and the main part of the square optimised so that no number takes more than four logical operations to put in its place, where a logical operation is any number of the same kind of movement.

Thank you for keeping me updated of your improvements! And I really mean it, it's nice to see that you really liked this challenge. :-)

@Charlie Yeah, it looks like I've approximated the algorithm Kirill found, although my last row probably isn't optimal yet, although I do at least avoid that expensive swap operation to fix the last two elements.

Maybe it would have been better to pose this challenge with a single, fixed matrix as the only test case, and set the winning criterion to be just the size of the found path to solve it, had I known before that this problem had a O(n^2) solution. Would you consider porting this answer to a new question with such winning criterion?

@Charlie I don't think I would, sorry, because that would probably be a much harder problem.

@Charlie I've now come up with a major optimisation for the bottom row, but I think that's the last change I'm going to be making to this answer.

This challenge got me my code challenge bronze tag badge! Thanks for the votes!


text:
Track an object in 2d space
Description
The task of this challenge is to devise a program or function that tracks a given object in an \$n×n\$ space.
I/O
Your program will be given 3 inputs, which may be taken in any sensible way:
n will be the size of the plane's side. (so, for \$n=5\$, your plane will be \$5×5\$). You may assume n will always be an odd integer.
s will be the starting position of the object, given as a pair of \$(x, y)\$ coordinates.
D will be a vector of ordered pairs. D will follow the format \$D = [(d_0,t_0),(d_1,t_1),...,(d_n,t_n)]\$, where \$d_k\$ will always be one of 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW', for the cardinal and primary intercardinal directions, and \$t_k\$ will be an integer for the number of 'ticks'.
Given these inputs, your program must output a tracking of the object in the plane.
Rules
The output must contain the plane's boundaries. E.g.:

- 21012 +
+┌─────┐
2│     │
1│     │
0│     │
1│     │
2│     │
-└─────┘

would be an example of an empty \$5×5\$ plane. The numbers above and to the side are for reference only and don't need to be printed.
You may use whatever character(s) for the boundaries, as long as it's not whitespace (or renders as whitespace). The characters you choose must delineate the full plane, meaning that there can be no gaps between them.

Some acceptable planes include:

┌──┐  ....  ----  +--+
│  │  .  .  |  |  |  |
│  │  .  .  |  |  |  |
└──┘; ....; ----; +--+

Nonacceptable planes include:

      ....  ....  ++++  .  .
            .  .  +  +  .  .
            .     +  +  .  .
    ; ....; ....; +  +; .  .

The object to be tracked may be whatever character you choose, as long as it only occupies 1 space on the plane and is different from the boundary characters.
The trace of the tracked object may also be whatever characters you choose, as long as they only occupy 1 space on the plane and are different from the object.
For each element \$(d_k,t_k)\$ in \$D\$, the object must move \$t\$ spaces towards \$d\$, and leave a trace behind.
If the object would hit a boundary, it'll be reflected. If the object still has any moves left, it'll keep moving in the direction it was reflected to.
For reference, these directions reflect to each other:
\$N\rightleftharpoons S\$ → when the top or bottom boundary is met;
\$E\rightleftharpoons W\$ → when a lateral boundary is met;
The final output will contain the newest possible traces, that is, if the object would leave a trace in a space where there's already a trace, the newer trace character will overwrite the older.
As usual, standard loopholes are forbidden by default.
Scoring:
This is a code-golf challenge.
Examples:
Input: \$n=5\$, \$s=(0,0)\$, \$D=[('NW',2),('S',2),('E',1)]\$
Working it out:
\$t=0\$

    0
 ┌─────┐
 │     │
 │     │
0│  ○  │
 │     │
 │     │
 └─────┘

\$t=2\$

    0
 ┌─────┐
 │○    │
 │ \   │
0│  \  │
 │     │
 │     │
 └─────┘

\$t=4\$

    0
 ┌─────┐
 │∧    │
 │|\   │
0│○ \  │
 │     │
 │     │
 └─────┘

\$t=5\$, which will be the output.

    0
 ┌─────┐
 │∧    │
 │|\   │
0│└○\  │
 │     │
 │     │
 └─────┘

(The 0s are just for reference, and they don't need to be in the final output.)

Input: \$n=9\$, \$s=(3,-1)\$, \$D=[('N',2),('SW',8),('SE',3),('NE',8)]\$
Notice that, when \$t=10\$:

      0
 ┌─────────┐
 │         │
 │         │
 │         │
 │       ∧ │
0│      /| │
 │ ○   / | │
 │⟨   /    │
 │ \ /     │
 │  ∨      │
 └─────────┘

The object has been reflected twice: once when reaching the bottom of the plane while going towards the \$SW\$, where it reflects to the \$NW\$; then once again when reaching the left side of the plane, where \$NW\$ reflects to \$NE\$.
The final output comes at \$t=21\$:

      0
 ┌─────────┐
 │    ○    │
 │     \   │
 │      \  │
 │       \ │
0│      /|⟩│
 │ ∧   / / │
 │⟨ \ / /  │
 │ \ \ /   │
 │  ∨ ∨    │
 └─────────┘

Test cases:
Input: \$n=5\$, \$s=(0,0)\$, \$D=[('NW',2),('S',2),('E',1)]\$
Output:

    0
 ┌─────┐
 │∧    │
 │|\   │
0│└○\  │
 │     │
 │     │
 └─────┘

Input: \$n=9\$, \$s=(3,-1)\$, \$D=[('N',2),('SW',8),('SE',3),('NE',8)]\$
Output:

      0
 ┌─────────┐
 │    ○    │
 │     \   │
 │      \  │
 │       \ │
0│      /|⟩│
 │ ∧   / / │
 │⟨ \ / /  │
 │ \ \ /   │
 │  ∨ ∨    │
 └─────────┘

Input: \$n=3\$, \$s=(1,1)\$, \$D=[('N',5),('W',5)]\$
Output:

   0
 ┌───┐
 │  |│
0│-○┐│
 │  |│
 └───┘

Input: \$n=11\$, \$s=(3,-5)\$, \$D=[('NW',8),('E',5),('SE',3),('SW',5),('N',6),('NE',10)]\$
Output:

       0
 ┌───────────┐
 │     ∧     │
 │    / \    │
 │┌--/-\ \   │
 │ \ |/ \ \  │
 │  \|   \ \ │
0│   |   /  ⟩│
 │   |\ /  / │
 │   | /  ○  │
 │   |/ \    │
 │   ∨   \   │
 │        \  │
 └───────────┘

Forgot to mention that this challenge was sandboxed.

Can we take 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW' as a 0-indexed (or 1-indexed) integer instead? So [('NW',2),('S',2),('E',1)] becomes [[7,2],[4,2],[2,1]] for example.

@KevinCruijssen sure, no problem. Just make sure to point that out in the answer.

Can we use a single trace character (such as x) or are we supposed to use 16 distinct trace characters to reflect all possible direction changes? (/,-,∧,┌, etc.)

@Arnauld yes, you're allowed to use a single trace character. I used more than one so it'd be easier to visualize the test cases, but it's not required. Just make sure the trace character is different from the character of the object being traced.

@Arnauld "The object to be tracked may be whatever character you choose, as long as it only occupies 1 space on the plane and is different from the boundary characters. The trace of the tracked object may also be whatever characters you choose, as long as they only occupy 1 space on the plane and are different from the object."

Maybe your initial outputs for the n=3 , s=(1,1), D=[('N',5),('W',5)] was correct after all.. The reflects for N,S,E,W against the wall will not stay at the same position for one turn when reflected, but immediately bounce back? So in that test case s=(1,1) and N=5 will go like this: s (1,1) -> n1 (0,1) -> n2 (-1,1) -> n3 (0,1) -> n4 (1,1) -> n5 (0,1) and not like this: s (1,1) -> n1 (1,1) -> n2 (0,1) -> n3 (-1,1) -> n4 (-1,1) -> n5 (0,1)? That's why I was confused, because the end position after ('N',5) is the same.. If the first, then your initial output was correct..

@KevinCruijssen Yes, I think it was correct.

@KevinCruijssen I guess everyone got confused with that one. The intended behaviour was the first one, yes. I'll re-fix that

The last test case is not correct. The input would be (′NW′,8),(′E′,5),(′SE′,2),(′SW′,5),(′N′,6),(′NE′,10)

@edc65 that has already been discussed and fixed though, and people who have already answered the question get the right output for those inputs.

What about using non consecutive integers for directions? for instance 1,2,4,5,6,8,9,10 (these are bitmasks)

@edc65 no problem, just make sure to point out which integer stands for which direction in your answer.

JavaScript (ES6), 228 bytes
Takes input as (n,x,y,[[dir,len],[dir,len],...]) where directions are encoded counterclockwise from \$0\$ for South to \$7\$ for South-West.
Outputs a string with 0 for a boundary, 1 for a trace and 3 for the final position.
(n,x,y,a)=>(g=X=>Y>n?'':(Y%n&&X%n&&a.map(([d,l],i)=>(M=H=>(h-X|v-Y||(k|=a[i+!l]?1:3),l--&&M(H=(h+H)%n?H:-H,h+=H,v+=V=(v+V)%n?V:-V)))(~-(D='12221')[d],V=~-D[d+2&7]),h=x+n/2,v=n/2-y,k=' ')&&k)+(X<n?'':`
`)+g(X++<n?X:!++Y))(Y=!++n)

Try it online!
How?
Initializing and drawing into a 'canvas' (i.e. a matrix of characters) is a bit tedious and lengthy in JavaScript.
This code is using a different strategy: instead of storing the output in a 2D array, it builds a string character by character, from left to right and from top to bottom. At each iteration:

We output a 0 if we're over a boundary.
Otherwise, we simulate the full path and see if it's crossing our current position. We output either 1 or 3 if it does, or a space otherwise.
We append a linefeed if we've reached the right boundary.

All in all, this may not be the shortest approach, but I thought it was worth trying.

Java 10, 350 343 340 336 334 332 bytes
(n,s,S,D)->{int N=n+2,x=N/2+s,y=N/2-S,i=N*N,t;var r=new char[N][N];for(;i-->0;)r[i/N][t=i%N]=i/N*t<1|i/N>n|t>n?'#':32;r[y][x]=42;for(var d:D)for(i=d[0];d[1]-->0;r[y+=i%7<2?1/y*2-1:i>2&i<6?1-y/n*2:0][x+=i>0&i<4?1-x/n*2:i>4?1/x*2-1:0]=42)i=y<2&i<2|y>=n&i>2&i<5?4-i:x<2&i>4|x>=n&i>0&i<4?8-i:y<2&i>6?5:y<n|i!=5?i:7;r[y][x]=79;return r;}

D is a 2D integer-array where the directions are 0-indexed integers: N=0, NE=1, E=2, SE=3, S=4, SW=5, W=6, NW=7. The starting x,y-coordinates will be two separate parameters s and S. The output is a character-matrix.
It uses # as border, * as trail, and O for the ending position (but can be all three be any ASCII characters in the unicode range [33,99] for the same byte-count if you'd want).
Try it online.
-8 bytes thanks to @ceilingcat.
Can definitely be golfed some more by simplifying the movements and in which direction we're traveling some more.
Explanation:
(n,s,S,D)->{            // Method with `n`,`s,S`,`D` parameters & char-matrix return-type
  int N=n+2,            //  Set `N` to `n+2`, since we use it multiple times
      x=N/2+s,          //  Calculate the starting `x` coordinate
      y=N/2-S,          //  Calculate the starting `y` coordinate
      i=N*N,            //  Index integer
      t;                //  Temp integer to save bytes
  var r=new char[N][N]; //  Result char-matrix of size `N` by `N`
  for(;i-->0;)          //  Loop `i` in the range (`N**2`, 0]
    r[i/N][t=i%N]=      //    Set the cell at position `i` divmod-`N` to:
      i/N*t<1|i/N>n|t>n?//     If we're at a border:
       '#'              //      Set the current cell to '#'
      :                 //     Else:
       32;              //      Set the current cell to ' ' (a space) instead
  r[y][x]=42;           //  Then set the starting position `x,y` to a '*'
  for(var d:D)          //  Loop over the `D` input:
    for(i=d[0];         //   Set `i` to the current direction
        d[1]-->0        //   Inner loop the current `d` amount of times
        ;               //     After every iteration:
         r[y+=          //      Change `y` based on the current direction
            i%7<2?      //       If the current direction is N, NE, or NW
             1/y*2-1    //        If we're at the top border:
                        //         Go one row down
                        //        Else
                        //         Go one row up
            :i>2&i<6?   //       Else-if the current direction is S, SE, or SW
             1-y/n*2    //        If we're at the bottom border
                        //         Go one row up
                        //        Else
                        //         Go one row down
            :           //       Else (directions E or W)
             0]         //        Stay in the same row
          [x+=          //      Change `x` based on the current direction
            i>0&i<4?    //       If the current direction is E, NE, or SE
             1-x/n*2    //        If we're NOT at the right border
                        //         Go one column to the right
                        //        Else:
                        //         Go one column to the left
            :i>4?       //       Else-if the current direction is W, NW, or SW
             1/x*2-1    //        If we're NOT at the left border:
                        //         Go one column to the left
                        //        Else:
                        //         Go one column to the right
            :           //       Else (directions N or S)
             0]         //        Stay in the same column
               =42)     //      And fill this new `x,y` cell with a '*'
      i=                //    Determine the new direction
        y<2&i<2|y>=n&i>2&i<5?4-i:x<2&i>4|x>=n&i>0&i<4?8-i:y<2&i>6?5:y<n|i!=5?i:7;
                        //     (See loose explanation below)
  r[y][x]=79;           //  And finally set the last `x,y` cell to 'O'
  return r;}            //  And return the result-matrix

y<2&i<2|y>=n&i>2&i<5?4-i:x<2&i>4|x>=n&i>0&i<4?8-i:y<2&i>6?5:y<n|i!=5?i:7 is a golfed version of this below by using 4-i and 8-i for most direction changes:
y<2?     // If we're at the top border
 i==0?   //  If the current direction is N
  4      //   Change it to direction S
 :i==1?  //  Else-if the current direction is NE
  3      //   Change it to SE
 :i==7?  //  Else-if the current direction is NW
  5      //   Change it to SW
 :       //  Else
  i      //   Leave the direction the same
:x<2?    // Else-if we're at the left border
 i==7?   //  If the current direction is NW
  1      //   Change it to NE
 :i==6?  //  Else-if the current direction is W
  2      //   Change it to E
 :i==5?  //  Else-if the current direction is SW
  3      //   Change it to SE
 :       //  Else
  i      //   Leave the direction the same
:y>=n?   // Else-if we're at the bottom border
 i==3?   //  If the current direction is SE
  1      //   Change it to NE
 :i==4?  //  Else-if the current direction is S
  0      //   Change it to N
 :i==5?  //  Else-if the current direction is SW
  7      //   Change it to NW
 :       //  Else
  i      //   Leave the direction the same
:x>=n?   // Else-if we're at the right border
 i==1?   //  If the current direction is NE
  7      //   Change it to NW
 :i==2?  //  Else-if the current direction is E
  6      //   Change it to W
 :i==3?  //  Else-if the current direction is SE
  5      //   Change it to SW
 :       //  Else
  i      //   Leave the direction the same
:        // Else
 i       //  Leave the direction the same

Charcoal, 74 bytes
ＮθＪ⊘⊕θ⊘⊕θＵＲ±⊕⊕θＪＮ±ＮＦＡ«≔⊟ιζＦ⊟ι«≔ζδ↷δ¶Ｆ›⊗↔ⅈθ≦±ζＦ›⊗↔ⅉθ≦⁻⁴ζ≧﹪⁸ζ↷⁴¶↶⁴↶δ↷ζ*¶↶ζＰo

Try it online! Link is to verbose version of code. Takes input in the format n, x, y, d where d is an array of arrays of [distance, direction] pairs where the direction is a numerical encoding 0 = south clockwise to 7 = south east. Explanation:
ＮθＪ⊘⊕θ⊘⊕θＵＲ±⊕⊕θ

Input n and draw a box whose interior is that size centred on the origin.
ＪＮ±Ｎ

Input and jump to x and y (but negate y because Charcoal's y-axis is increasing down).
ＦＡ«

Loop over the entries in d.
≔⊟ιζ

Extract the initial direction.
Ｆ⊟ι«

Repeat for the desired distance.
≔ζδ

Save the direction.
↷δ¶

Make an experimental move in that direction.
Ｆ›⊗↔ⅈθ≦±ζ

If this goes off the sides then flip the direction horizontally.
Ｆ›⊗↔ⅉθ≦⁻⁴ζ

If this goes off the top or bottom then flip the direction vertically.
≧﹪⁸ζ

Reduce the direction modulo 8 (the Pivot commands only accept values from 0 to 7).
↷⁴¶↶⁴

Undo the experimental move.
↶δ↷ζ*¶

Face the correct direction, and then print a trace and move.
↶ζＰo

Face back to the default direction, and print the object in the current position.

C (gcc), 352 323 bytes
Golfed down 29 bytes thanks to ceilingcat.
#define G(x,a)x+=a=x<2|x>m-3?-a:a
#define A(p)atoi(v[p])
m,r,c,x,y,s,a,b;main(q,v)int**v;{m=A(1)+2;int f[r=m*m];for(x=A(2)+m/2;r--;f[r]=32);for(y=A(s=3)+m/2;++s<q;)for(a=cos(A(s)*.8)*2,b=sin(A(s)*.8)*2,c=A(++s);c--;G(y,b),f[y*m+x]=42)G(x,a);for(f[y*m+x]=64;++r<m;puts(""))for(c=0;c<m;c++)putchar(c%~-m&&r%~-m?f[r*m+c]:35);}

Try it online!
The program takes input as command line arguments (like a.out 10 1 1 3 5 0 4 7 2):

the first argument is the field size,
the next two are initial coordinates \$(x,y)\$ of the actor,
all pairs of arguments starting from the fourth are \$(d, t)\$ pairs where \$d\$ is direction (represented as a number 0..7, starting from 0=E and turning clockwise) and \$t\$ is number of steps.

Explanation
// Update the coordinate AND simultaneously modify the direction (if needed)
#define G (x, a) x += a = x < 2 || x >= m - 2 ? -a : a

// Get the numeric value of an argument
#define A (p) atoi (v[p])

// variables
m, // width and height of the array with field data
r, c, // helpers
x, y, // current coordinates of the actor
s, // helper
a, b; // current direction of the movement

main (q, v) char **v;
{
    // array size is field size + 2 (for borders)
    m = A (1) + 2;

    // allocate the array
    int f[r = m * m];

    // fill the array with spaces,
    for
    (
        // but first get x of the actor
        x = A (2) + m / 2;

        r--;

        f[r] = 32
    );

    // trace: iterate over remaining commandline argument pairs
    for
    (
        // but first get y of the actor
        y = A (s = 3) + m / 2;

        ++s < q; // loop until no args left
    )
        // for each such pair
        for
        (
            a = cos (A (s) * .8) * 2,  // get the x-increment
            b = sin (A (s) * .8) * 2, // get the y-increment
            c = A (++s);  // then get the number of steps

            c--;

            // after each step:
            G (y, b), // update y and maybe the y-direction
            f[y * m + x] = 42 // draw the trail
        )
            G (x, a); // update x and maybe the x-direction

   // output
   for
   (
       f[x * m + y] = 64; // put a @ to the current position of the actor
       ++r < m; // r == -1 at the beginning of the loop so preincrement

       puts("") // terminate each row with newline
   )
       // iterate over columns in the row
       for (c = 0; c < m; c++)
           putchar
           (
               c % ~ -m && r % ~ -m ? // if it is not a border cell,
               f[r * m + c] // output the character from the array
               : 35 // otherwise output the #
           );
}

I believe your code is missing the object output at the end position, since The trace of the tracked object may also be whatever characters you choose, as long as they only occupy 1 space on the plane and are different from the object. Other than that, it looks good to me.

Oops, I totally missed that, thanks for noticing J.Sallé . Luckily the correction did not make the program longer.

JavaScript, 206 bytes
Takes input as (n,x,y,[[dir,len],[dir,len],...]) where directions are encoded using bitmasks :
S : 1
N : 2
E : 4
W : 8
SE: 5 (1|4)
SW: 9 (1|8)
NE: 6 (2|4)
NW:10 (2|8)

Outputs a string with
- 1 for top and bottom boundary
- 4 for left and right boundary
- 5 for corners
- 0 for trace
- 8 for the final position.

The different values for boundaries are used to evaluate the next direction
(n,x,y,d)=>(Q=[e=`
5`+'1'[R='repeat'](n)+5,o=n+3,-o,c=[...e+(`
4`+' '[R](n)+4)[R](n)+e],1,1+o,1-o,,-1,o-1,~o],p=1-o*(~n/2+y)-~n/2+x,c[d.map(([q,s])=>{for(a=q;s--;p+=Q[a^=c[p+Q[a]]*3])c[p]=0}),p]=8,c.join``)

Less golfed
F=(n,x,y,d) => (
  o = n+3, // vertical offset, accounting for boundaries and newline
  // Q = offsets for different directions, bitmask indexed
  Q = [,  // 0000 no direction
     o,   // 0001 S
     -o,  // 0010 N
     ,    // 0011 NS - invalid
     1 ,  // 0100 E
     1+o, // 0101 SE
     1-o, // 0110 NE
     ,    // 0111 NSE - invalid
     -1,  // 1000 W
     o-1, // 1001 SW
    -o-1],// 1010 NW

  e = `\n5`+'1'.repeat(n)+5, // top and bottom boundary
  c = [...e + (`\n4` + ' '.repeat(n) + 4).repeat(n) + e], // canvas
  p = 1 - o*(~n/2+y) - ~n/2 + x, // start position
  d.map( ([q,s]) => { // repeat for each element in 'd'
    a = q; // starting offset pointer - will change when bounce
    while( s-- )
    {
      c[p] = 0; // trace
      b = c[p + Q[a]] // boundary value or 0 (space count 0)
      a ^= b * 3 // xor with 0 if no bounce, else 3 or 12 or 15
      p += Q[q]  // advance position
    }
  })
  c[p] = 8, // set end position
  c.join``
)

TEST

var F=
(n,x,y,d)=>(Q=[e=`
5`+'1'[R='repeat'](n)+5,o=n+3,-o,c=[...e+(`
4`+' '[R](n)+4)[R](n)+e],1,1+o,1-o,,-1,o-1,~o],p=1-o*(~n/2+y)-~n/2+x,c[d.map(([q,s])=>{for(a=q;s--;p+=Q[a^=c[p+Q[a]]*3])c[p]=0}),p]=8,c.join``)

var out=x=>O.textContent+=x

var test=(n,x,y,d)=>{
  var dd = d.map(([d,s])=>[,'S','N',,'E','SE','NE',,'W','SW','NW'][d]+' '+s)
  out([n,x,y]+' ['+dd+']')
  out(F(n,x,y,d))
  out('\n\n')
}

test(5,0,0,[[10,2],[1,2],[4,1]])
test(9,3,-1,[[2,2],[9,8],[5,3],[6,8]])
test(11,3,-5,[[10,8],[4,5],[5,2],[9,5],[2,6],[6,10]])
<pre id=O></pre>

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Is the date alphabetical?
Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.
An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered specifically in M - D - Y order). For example, Sept. 26 2018 is an alphabetical date:
September 26th 2018 -> September twenty-sixth two thousand eighteen

September
Twenty-sixth
Two thousand eighteen

Another way to think of this challenge: "are the elements of a given date lexically sorted?"
Notes:

2018 is represented as "two thousand eighteen," not "twenty eighteen" or "two zero one eight." For another example, the year 1456 would be represented as "one thousand four hundred fifty-six," not "fourteen fifty-six."
26th is represented as "twenty-sixth," not "twenty-six."
Each element of the date is considered as a whole. This is why 2018 doesn't automatically fail even though the "e" in eighteen comes before the "t" in two.

The following dates are not alphabetical:

September 2nd 2018 ("second" should sort ahead of "September")
April 30th 4000 ("four thousand" should sort ahead of "thirtieth")

Additional Rules:

You will receive the date as a string, formatted like YYYY-MM-DD. The year will always have four digits, and the month and day will always have two digits each. Zero-padding is not represented in the string conversion (e.g., '2000-01-01' is 'January first two thousand' as you'd expect).
You may assume that dates will always be valid (no February 30th, no Smarch 1st) and that the value of the year will be positive (no dates B.C.), but the date may be far in the future ("in the year two nine thousand...").
You should return a truthy or falsey value, not necessarily a boolean True or False. If you do this in Javascript and want to return '0' and 0 that's fine. Of course, if you want to return a boolean, feel free.
Standard loopholes are forbidden.
This is code-golf

More Examples of Alphabetical Dates

2066-01-02 (January second, two thousand sixty-six)
1000-04-08 (April eighth, one thousand)
6000-08-01 (August first, six thousand)

More Examples of Non-Alphabetical Dates

1066-01-02 (January second, one thousand sixty-six)
1000-04-07 (April seventh, one thousand)
8000-08-01 (August first, eight thousand)

Lousy Smarch weather.

@Arnauld Um, no? Looks like 2018-09-02 is falsy, while 2018-09-26 is truthy (when given as in the question).

@EriktheOutgolfer Right. I totally misread the challenge. (Maybe it should be rephrased as Is the date lexically sorted? or something like that.)

@Arnauld I tweaked the first paragraph and included a line with your suggested wording a bit further in, hopefully to the delight of future readers. Thank you!

All the years in your examples and test cases are now in the form N0## resulting N thousand ##. Would a year where the second digit isn't a zero also start with N thousand, or would it be more how people would actually say year in general (i.e. will 1991 be one thousand nine hundred and ninety-one or nineteen hundred ninety-one).

IMO, this post should contain the details of how to convert the number of year to its name. And it currently unclear, at least to me.

The year is always the spelled-out number. 1444 is one thousand four hundred forty-four. 1991 is one thousand nine hundred ninety-one.

05AB1E, 66 62 58 bytes
0ì'-¡ÀDΣ2£<•88ΛηΣλšëÇñ0é≠>sîä&ζp°Lć®-αÅ®`•21вŽqT32в£Nèsè}Q

Try it online or verify all examples mentioned in the challenge.
Explanation:
0ì         # Prepend a "0" before the (implicit) input
           #  i.e. "2018-09-26" → "02018-09-26"
  '-¡     '# Then split on "-"
           #  i.e. "02018-09-26" → ["02018","09","26"]
     À     # Rotate it once to the left (so [0yyyy,MM,dd] becomes [MM,dd,0yyyy])
           #  i.e. ["02018","09","26"] → ["09","26","02018"]
D          # Duplicate this list
 Σ         # Sort this list by:
  2£       #  Leave only the first 2 digits of the current item
           #  (which is why the prepended 0 was there at the start for the year)
           #   i.e. "09" → "09"
           #   i.e. "02018" → "02"
    <      #  Decrease it by 1 to make it 0-indexed
           #   i.e. "09" → 8
  •88ΛηΣλšëÇñ0é≠>sîä&ζp°Lć®-αÅ®`•21в
           #  Push the list [7,3,7,0,7,7,7,0,13,10,10,0,4,12,17,6,4,17,15,2,9,17,2,19,17,6,4,17,15,2,9,19,19,19,19,19,19,19,19,19,19,17,17,11,20,18,5,5,16,14,1,8]
   ŽqT32в  #  Push the list [12,31,9]
         £ #  Split the first list into parts of that size: [[7,3,7,0,7,7,7,0,13,10,10,0],
           #    [4,12,17,6,4,17,15,2,9,17,2,19,17,6,4,17,15,2,9,19,19,19,19,19,19,19,19,19,19,17,17],
           #    [11,20,18,5,5,16,14,1,8]]
   Nè      #  Then only leave the relevant list of the three based on the sort-index
     s     #  Swap to get the earlier integer at the top of the stack again
      è    #  And use it to index into the list
           #   i.e. [7,3,7,0,7,7,7,0,13,10,10,0] and 8 → 13
 }         # Close the sort
  Q        # And check if the sorted list is equal to the duplicated list,
           # so whether the order is still [MM,dd,0yyyy] after sorting
           # (and output the result implicitly)

See this 05AB1E tip of mine (section How to compress integer lists?) to understand why •88ΛηΣλšëÇñ0é≠>sîä&ζp°Lć®-αÅ®`•21в is [7,3,7,0,7,7,7,0,13,10,10,0,4,12,17,6,4,17,15,2,9,17,2,19,17,6,4,17,15,2,9,19,19,19,19,19,19,19,19,19,19,17,17,11,20,18,5,5,16,14,1,8] and ŽqT32в is [12,31,9].
Additional general explanation:
The sort function will sort all three types (day, month, year) at the same time, where we will return a truthy value only if M < D < Y (where these D, M, and Y are the values we've retrieved from the compressed lists).
Why these three lists mentioned above? If we put all words in order, categorized by type, we have the following order:
Sorting nr      Type        Which?

0               Month       April, August, December
1               Year        eight thousand
2               Day         eighteenth, eighth, eleventh
3               Month       February
4               Day         fifteenth, fifth, first
5               Year        five thousand, four thousand
6               Day         fourteenth, fourth
7               Month       January, July, June, March, May
8               Year        nine thousand
9               Day         ninteenth, ninth
10              Month       November, October
11              Year        one thousand
12              Day         second
13              Month       September
14              Year        seven thousand
15              Day         seventeenth, seventh
16              Year        six thousand
17              Day         sixteenth, sixth, tenth, third, thirteenth, thirtieth, thirty-first
18              Year        three thousand
19              Day         twelfth, twentieth, twenty-first through twenty-ninth
20              Year        two thousand

If we then look at each type individually and their original order (one thousand, two thousand, etc. for years; January, February, etc. for months; and first, second, etc. for days), the sorting numbers mentioned above are in these orders:
Years:  [11,20,18,5,5,16,14,1,8]
Months: [7,3,7,0,7,7,7,0,13,10,10,0]
Days:   [4,12,17,6,4,17,15,2,9,17,2,19,17,6,4,17,15,2,9,19,19,19,19,19,19,19,19,19,19,17,17]

JavaScript (ES6), 101 bytes
Saved 4 bytes thanks to @Shaggy
Returns \$0\$ or \$1\$.
s=>'_414044406550'[[,m,d]=s.split`-`,+m]<(d=`_268328715819832871${6e12-12}`[+d])&d<'_6A9338704'[s[0]]

Try it online!
or Test all dates!
(includes some invalid inputs)
How?
Each month, each day and each year is mapped to an ID in \$[0..10]\$ (\$M\$, \$D\$ and \$Y\$ respectively) according to the following table. We then test if we have \$M<D\$ and \$D<Y\$.
The last part of the lookup string for day IDs is slightly compressed by using ${6e12-12}, which expands to 5999999999988 (19th to 31st).
  M | Month                D | Day                  Y | Year (millennium)
----+----------------    ----+----------------    ----+-------------------
  0 | April                1 | eighth               0 | eight thousand
  0 | August               1 | eleventh           ----+-------------------
  0 | December             1 | eighteenth           3 | four thousand
----+----------------    ----+----------------      3 | five thousand
  1 | February             2 | first              ----+-------------------
----+----------------      2 | fifth                4 | nine thousand
  4 | January              2 | fifteenth          ----+-------------------
  4 | March              ----+----------------      6 | one thousand
  4 | May                  3 | fourth             ----+-------------------
  4 | June                 3 | fourteenth           7 | seven thousand
  4 | July               ----+----------------    ----+-------------------
----+----------------      5 | ninth                8 | six thousand
  5 | October              5 | nineteenth         ----+-------------------
  5 | November           ----+----------------      9 | three thousand
----+----------------      6 | second             ----+-------------------
  6 | September          ----+----------------     10 | two thousand
                           7 | seventh
                           7 | seventeenth
                         ----+----------------
                           8 | third
                           8 | sixth
                           8 | tenth
                           8 | thirteenth
                           8 | sixteenth
                           8 | thirtieth
                           8 | thirty-first
                         ----+----------------
                           9 | twelfth
                           9 | twentieth
                           9 | twenty-*

104 bytes

@Shaggy Oops... This m= was, of course, completely useless. Thanks. :)

That was quick! Nicely done. The "test all dates" and illustrative table are especially appreciated.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Is the word coprime?
Given a word, treat every letter as its number in English alphabet (so a becomes 1, b becomes 2, z becomes 26 and so on), and check if all of them, including duplicates, are pairwise coprime.
The input is exactly one word of lowercase English letters. The output is the fact if the word is coprime: any truthy/falsey values, but only two variants of them. Standard loopholes are forbidden.
Test cases:

man: True
day: True (thanks to Ørjan Johansen)
led: False (l=12 and d=4 have gcd=4)
mana: True (though a occurs multiple times, 1 and 1 are coprimes)
mom: False (gcd(13,13)=13))
of: False (thanks to xnor; though 15∤6, gcd(15,6)=3)
a: True (if no pairs of letters, treat the word as coprime too)

This is a code-golf, so the shortest code in bytes wins!

Can we output 0 if they are coprime and 1 if not?

Suggested test case that would have caught a buggy answer: day: True

I'd also suggest of: False to have a false example where no value is a multiple of another.

@dylnan no, it's contr-intuitive. Anyway, Dennis'es answer is better ;-)

@LuisMendo any truthy/falsey, but only two.

Wolfram Language (Mathematica), 36 bytes
CoprimeQ@@LetterNumber@Characters@#&

Try it online!

Wolfram Language (Mathematica), 33 bytes

Thanks to Misha Lavrov for this three bytes shorter version.

CoprimeQ@@(ToCharacterCode@#-96)&
Try it online!

CoprimeQ@@(ToCharacterCode@#-96)& is three bytes shorter.

Jelly, 10 bytes
ØaiⱮgþ`P$Ƒ

Try it online!
How it works
ØaiⱮgþ`P$Ƒ  Main link. Argument: s (string)

Øa          Yield "abc...xyz".
  iⱮ        Find the 1-based index of each c of s in "abc...xyz".
        $Ƒ  Call the monadic chain to the left.
            Yield 1 if the result is equal to the argument, 0 if not.
    gþ`       Take the GCDs of all pairs of indices, yielding a matrix.
       P      Take the columnwise product.
            For coprimes, the column corresponding to each index will contain the
            index itself (GCD with itself) and several 1's (GCD with other indices),
            so the product is equal to the index.

Haskell, 48 bytes
((==).product<*>foldr1 lcm).map((-96+).fromEnum)

Try it online!
Very straightforward: converts the string to a list of numbers and then checks whether the product is equal to the LCM.

Python 2 - 122 118 bytes
-4 bytes thanks to @JonathanAllan
This is honestly terrible, but I've spent way too long to not post this.
from fractions import*
def f(n):r=reduce;n=[ord(i)-96for i in n];return r(lambda x,y:x*y/gcd(x,y),n)==r(int.__mul__,n)

Try it Online

96 for ~> 96for; lambda x,y:x*y ~> int.__mul__.

Pyth, 9 bytes
{Ism{PhxG

Test suite
Explanation:
{Ism{PhxG   | Full code
{Ism{PhxGdQ | With implicit variables filled
------------+------------------------------------------
   m      Q | For each char d in the input:
    {P      |  list the unique prime factors of
      hx d  |  the 1-based index of d in
        G   |  the lowercase alphabet
  s         | Group all prime factors into one list
{I          | Output whether the list has no duplicates

did Pyth just outgolf Jelly?

05AB1E, 11 bytes
Ç96-2.Æ€¿PΘ

Try it online!
Explanation
Ç96-         # convert to character codes and subtract 96
    2.Æ      # get all combinations of size 2
       €¿    # gcd of each pair
         P   # product of gcds
          Θ  # is true

Is the final Θ really necessary?

@Mr.Xcoder: No I suppose not. I just assumed we needed to use 2 distict values, but now that I look there is nothing in the challenge about it. Truthy/Falsy should be okay then.

@Emigna I added a clarification for that: there should be only two variants of output values.

@bodqhrohro: OK. I rolled back to the previous version to conform to this new requirement.

Brachylog, 11 bytes
ạ{-₉₆ḋd}ᵐc≠

Try it online!
Explanation
ạ{-₉₆ḋd}ᵐc≠
ạ              Split the input into its character codes
 {     }ᵐ      For each one
  -₉₆          Subtract 96 (a -> 1, b -> 2 etc.)
     ḋd        And find the unique (d) prime factors (ḋ)
         c     Combine them into one list
          ≠    And assert they are all different

Perl 6, 34 32 bytes
-2 bytes thanks to nwellnhof
{[lcm](@_)==[*] @_}o{.ords X-96}

Try it online!
An anonymous codeblock that takes a string and returns True or False. If the lowest common multiple of the letters is equal to the product of the letters than they share no common divisors.
Explanation:
                     {.ords X-96}  # Convert the letters to a list of numbers
 {                 }o              # Pass result to the next codeblock
  [lcm](@_)           # The list reduced by the lcm
           ==         # Is equal to?
             [*] @_   # The list reduced by multiplication

If I'm not mistaken, does this work? (21 bytes)

@ConorO'Brien No, you've just mapped a to 0 lol

@JoKing oh, ok lol

That strategy was buggy, test case: day.

@ØrjanJohansen Ah right, rolled back

32 bytes

Python 2, 77 68 64 bytes
lambda a:all(sum(ord(v)%96%i<1for v in a)<2for i in range(2,26))

Try it online!
Basically, (some pair in the input is not co-prime) if and only if (there is a number i > 1 which divides more than one of the inputs).

Looks like we had the same idea but you beat me by a few minutes :) Can't you save those 2 bytes by using all and <2 though?

Python 3, 61 59 bytes
Using python bytes as argument:
lambda s:all(sum(c%96%x<1for c in s)<2for x in range(2,24))

The last divisor to check is 23, the largest prime below 26.
Try it online!
Thanks to @Dennis for saving two bytes.

c%96%x<1for c in s saves 2 bytes.

JavaScript (Node.js), 60 bytes
f=(s,v=23)=>n=v<2||f(s,v-1)&&Buffer(s).every(c=>c%32%v||n--)

Try it online!

Using the idea of Buffer from Shieru Asakoto's post.
Thanks to Arnauld, saved 5 bytes.

62 bytes by going recursive and using every(c=>c%32%v||n--,n=1).

@Arnauld Thanks. And I golfed 2 more bytes from it.

59

Markov algorithm, as interpreted by eMain (474 484 463 bytes, 76 78 76 rules)
a->
d->b
f->bc
h->b
i->c
j->be
l->bc
n->bg
o->ce
p->b
q->q
r->bc
t->be
u->cg
v->bk
x->bc
y->e
z->bm
cb->bc
eb->be
gb->bg
kb->bk
mb->bm
qb->bq
sb->bs
wb->bw
ec->ce
gc->cg
kc->ck
mc->cm
qc->cq
sc->cs
wc->cw
ge->eg
ke->ek
me->em
qe->eq
se->es
we->ew
kg->gk
mg->gm
qg->gq
sg->gs
wg->gw
mk->km
qk->kq
sk->ks
wk->kw
qm->mq
sm->ms
wm->mw
sq->qs
wq->qw
ws->sw
bb->F
cc->F
ee->F
gg->F
kk->F
mm->F
qq->F
ss->F
ww->F
b->
c->
e->
g->
k->
m->
q->
s->
w->
FF->F
TF->F
!->.
->!T

The first 17 rules factor the "composite letters" into their "prime letter" factors, ignoring multiplicity. (E.g., t becomes be because 20 factors as a product of a power of 2 and a power of 5.)
The next 36 rules (such as cb->bc) sort the resulting prime factors.
The next 9 rules (such as bb->F) replace a repeated prime factor by F, then 9 more rules (such as b->) get rid of the remaining single letters.
At this point, we either have an empty string, or a string of one or more Fs, and the last rule ->!T adds a !T at the beginning. Then the rules FF->F and TF->F simplify the result to either !T or !F. At this point, the !->. rule applies, telling us to get rid of ! and halt: returning T for a coprime word, and F otherwise.
(Thanks to bodqhrohro for pointing out a bug in the earlier version that caused this code to give an empty string on input a.)

Gives neither T nor F on a testcase.

@bodqhrohro Thanks for the catch! (In the end, my byte count went down, because I realized I was counting every newline as two bytes.)

Jelly, 11 bytes
ŒcO_96g/€ỊẠ

Try it online!

Thanks to Dennis for NOTing my booleans

ŒcO_96g/€ỊẠ
Œc           All pairs of characters without replacement
  O          Code point of each character
   _96       Subtract 96. a->1, b->2, etc.
        €    For each pair:
      g/       Get the greatest common denominator
         Ị   abs(z)<=1? If they are all 1 then this will give a list of 1s
          Ạ  "All". Gives 1 if they are coprime, 0 if not.

ỊẠ flips the Booleans.

J, 36 bytes
[:(1 =[:*/-.@=@i.@##&,+./~)_96+a.&i.

Ungolfed
[: (1 = [: */ -.@=@i.@# #&, +./~) _96 + a.&i.

Explanation
[: (                            ) _96 + a.&i.  NB. apply fn in parens to result of right
                                  _96 + a.&i.  NB. index within J's ascii alphabet, minus 96.
                                               NB. gives index within english alphabet
   (1 =                         )              NB. does 1 equal...
   (    [: */                   )              NB. the product of...
   (                    #&,     )              NB. Flatten the left and right args, and then copy
   (                        +./~)              NB. right arg = a table of cross product GCDs
   (          -.@=@i.@#         )              NB. the complement of the identity matrix.
                                               NB. this removes the diagonal.

Try it online!

[:(1=[:*/+./~#&,~#\~:/#\)_96+a.&i. for 34 bytes
You had a space in `1 =' :)

Thanks @GalenIvanov

MATL, 10 bytes
96-YF&fdA&

Outputs 1 for coprime, 0 otherwise.
Try it online! Or verify all test cases.
Explanation
Consider input 'man' for example.
96-  % Implicit input: string. Subtract 96 from (the codepoint of) each element
     % STACK: [13 1 14]
YF   % Exponents of prime factoriation. Each number produces a row in the result
     % STACK: [0 0 0 0 0 1;
               0 0 0 0 0 0;
               1 0 0 1 0 0]
&f   % Two-output find: pushes row and column indices of nonzeros
     % STACK: [3; 3; 1], [1; 4; 6]
d    % Consecutive differences
     % STACK: [3; 3; 1], [3; 2]
A    % All: gives true if the array doesn't contain zeros
     % STACK: [3; 3; 1], 1
&    % Alternative in/out specification: the next function, which is implicit
     % display, will only take 1 input. So only the top of the stack is shown

Python 3, 90 89 bytes
-1 byte by numbermaniac
f=lambda q,*s:s==()or all(math.gcd(ord(q)-96,ord(w)-96)<2for w in s)and f(*s)
import math

Try it online!
Use as f(*'man').

Retina 0.8.2, 45 bytes

;
{`\w
#$&
}T`l`_l
M`;(##+)\1*;(#*;)*\1+;
^0

Try it online! Explanation:

;

Insert separators between each letter and at the start and end.
{`\w
#$&

Prepend a # to each letter.
}T`l`_l

Move each letter 1 back in the alphabet, deleting the as. Then repeat the above operations until all the letters have been deleted. This converts each letter to its 1-based alphabet index in unary.
M`;(##+)\1*;(#*;)*\1+;

Test whether any two values share a common factor greater than 1. (This can find more than one pair of letters with a common factor, e.g. in the word yearling.)
^0

Check that no common factors were found.

R + pracma library, 75 bytes
function(w){s=utf8ToInt(w)-96;all(apply(outer(s,s,pracma::gcd),1,prod)==s)}
I'm using the gcd function in the pracma library as to my knowledge R does not have a built-in for that. I'm using the approach of comparing the product of the gcds to the numbers themselves.
65 bytes (credit: @J.Doe)
function(w)prod(outer(s<-utf8ToInt(w)-96,s,pracma::gcd))==prod(s)

Japt, 14 bytes
;à2 e_®nR+CÃrj

Try it online!
Takes input as an array of characters.
How it works
;à2 e_m_nR+C} rj
;                 Use alternative predefined variables (in this case, C = "a-z")
 à2               Get all pairs
    e_            Does all pairs satisfy that...
      m_            when the character pair is mapped over...
        nR+C}         conversion from "a-z" to [1..26]
              rj    then the two numbers are coprime?

Ruby, 56 bytes
->s{s.bytes.combination(2).all?{|a,b|2>(a-96).gcd(a-b)}}

Try it online!

Japt, 13 bytes
Takes input as a character array.
®c uHÃà2 e_rj

Try it or verify all test cases

Java 10, 86 bytes
a->{var r=1>0;for(int i=1,s=0;++i<24;r&=s<2,s=0)for(var c:a)s+=c%96%i<1?1:0;return r;}

Port of @Vincent's Python 3 answer.
Try it online.
Explanation:
a->{                 // Method with character-array parameter and boolean return-type
  var r=1>0;         //  Result-boolean, starting at true
  for(int s=0,       //  Sum integer, starting at 0
      i=1;++i<24     //  Loop `i` in the range (1, 24)
      ;              //    After every iteration:
       r&=s<2,       //     If the sum is >= 2: change the result to false
       s=0)          //     And reset the sum to 0
     for(var c:a)    //   Inner loop over the input-characters
       s+=c%96%i<1?  //    If the current character modulo-96 is divisible by `i`
           1         //     Increase the sum by 1
          :          //    Else
           0;        //     Leave the sum the same
  return r;}         //  Return the result-boolean

Pyt, 23 18 bytes
ą1Ĩ6²-⁺ϼƑ⁻ž⁺ĐỤŁ⇹Ł=

Try it online!
ą                     implicit input (string); convert to array of characters
 1Ĩ6²-⁺               use bug in arbitrary-base radix interpretation code to
                      convert lowercase letters to integers
       ϼ              get unique prime factors for each number
        Ƒ             flatten array
         ⁻ž⁺          remove all 1s
            ĐỤŁ⇹Ł=    is the resulting list the same length as the list of its
                      unique elements?; implicit print

Original Approach (23 bytes)
ą1Ĩ6²-⁺ĐĐɐǤƑ⁻⇹ŁřĐɐ≠Ƒ*↑¬

Try it online!
ą                              implicit input (string); convert to array of characters
 1Ĩ6²-⁺                        abuses bug in arbitrary-base radix interpretation code to
                               convert lowercase letters to integers
       Đ                       duplicate top of stack
        ĐɐǤ                    get all GCD pairs
           Ƒ⁻                  flatten array, and decrement each element
             ⇹                 swap top two items on stack
              ŁřĐɐ≠Ƒ           creates matrix of all 1s except for the main diagonal,
                               which contains only 0s; then flattens that array
                    *↑¬        multiplies element-wise the two arrays, gets the max, and
                               logically negates that value

Outputs "True" if coprime, "False" if not

Vyxal, 9 bytes
øA2ḋvġΠċ¬

Try it Online (with test cases)
øA        # convert letters to index in alphabet
  2ḋ      # get all combinations of length 2
    vġ    # get the gcd of each
      Π   # get the product of this list
       ċ  # inequality to 1
        ¬ # logical not

Probably golfable.

APL(NARS), 16 chars, 32 bytes
{(×/p)=∧/p←⎕a⍳⍵}

This use method other used that LCM()=×/, it is fast but overflow if input array is enough long;
other alternative solutions a little slower:
{1=×/y∨y÷⍨×/y←⎕a⍳⍵}
{1=≢,⍵:1⋄1=×/{(2⌷⍵)∨1⌷⍵}¨{x←97-⍨⎕AV⍳⍵⋄(,x∘.,x)∼⍦x,¨x}⍵}

this below it seems 10 times faster(or+) than just above functions
∇r←h m;i;j;k;v
   r←i←1⋄k←≢v←97-⍨⎕AV⍳m
A: →F×⍳i>k⋄j←i+1⋄→C
B:   →E×⍳1≠(j⌷v)∨i⌷v⋄j←j+1
C:   →B×⍳j≤k
D: i←i+1⋄→A
E: r←0
F:
∇

i prefer this last because it is easier, faster, trusted (becaise less overflow possiblity), easier to write, and how it has to be (even if it has some bytes more...)

q, 121 111 bytes
{$[1=count x;1b;1b=distinct{r:{l:{$[0~y;:x;.z.s[y;x mod y]]}[y;]'[x];2>count l where l<>1}[x;]'[x]}[1+.Q.a?x]]}

JavaScript (Node.js), 87 82 bytes
a=>!/\b(11+)\1* (1+ )*\1+\b/.exec(Buffer(a).map(x=>w+=" ".padEnd(x-95,1),w="")&&w)

Try it online!
Original approach (87B)
a=>!(b=Buffer(a)).some((x,i)=>b.some((y,j)=>i-j&&(g=(p,q)=>q?g(q,p%q):p)(x-96,y-96)>1))

Try it online!

Stax, 16 bytes
è'B╕i4à!ùà╫æor4Z

Run and debug it
Explanation
2S{M{$e96-mm{E:!m|A     #Full program, unpacked, implicit input
2S                      #Generate all combinations of size 2
  {       m             #Map for each element
   M                    #Split into size of 1 element
    {       m           #Map for each element
     $e                 #Convert to number
       96-              #Subtract 96
           {    m       #Map for each element
            E:!         #Explode array onto stack, are they coprime
                 |A     #Are all elements of array truthy

Outputs 1 for True, 0 For false.
There is probably a better way to do the converting to number part, but it works.

Stax author here.  Thanks for giving stax a try!  Here's a program using your algorithm that packs to 10 bytes.  2SOF{96-F:!*  Let me know if you want to know more about it.  First one is free!

@recursive Thank you for making Stax! It's my golfing language of choice at the moment. I can see how your answer works and I'll have to keep working to improve my answers in the future.

Thunno, \$ 13 \log_{256}(96) \approx \$ 10.70 bytes
O96-2zQ.AgP1=

Attempt This Online!
Port of Emigna's 05AB1E answer.
Explanation
O96-2zQ.AgP1=  # Implicit input
O              # Ordinal of each character in the input
 96-           # Subtract 96 from each
    2zQ        # Combinations of length 2
       .Ag     # GCD of each pair
          P    # Product of this list
           1=  # Equals 1?
               # Implicit output


text:
PronunciationSort™
We all know of different fancy sorting algorithms, but none of these give us numbers in a way that's easy to pronounce. To remedy this, I propose using PronunciationSort™, the most natural way to sort lists of numbers.
Pronunciation
The official rules for pronouncing numbers (in this challenge) is that the digits are pronounced one by one, and the resulting string is sorted in lexicographic order. As an example, this means that the number 845 is pronounced "eight four five", and should be sorted accordingly.
Negative numbers
Negative numbers are pronounced by prepending the word "minus". Thus, -23 is pronounced as "minus two three". Note that this causes negative numbers to end up in the middle of the output, right between numbers starting with 4 (four) and 9 (nine).
As a guide, the official order of words for PronunciationSort™ is:

eight
five
four
minus
nine
one
seven
six
three
two
zero

That is,
8, 5, 4, -, 9, 1, 7, 6, 3, 2, 0

Input
A list of integers in the range \$[-999, 999]\$, containing at most 100 elements. Input as a list of strings is not permitted. If your language does not support input as list, it is permissible to give input as separate integers.
The input will not contain any invalid numbers, or any number starting with a 0 (except the number 0 itself). The input will generally not be sorted, it can be given in any order.
Output
The same integers, in PronunciationSort™ order. Note that the numbers should only be converted to their pronunciations to get the sorting, the output should not contain any strings.
Examples
For the examples, the middle step (wrapped in parentheses) only serves as a guide, and is not a part of the output.
[1, 2, 3] -> (['one', 'two', 'three']) -> [1, 3, 2]
[-1, 0, 1, 2] -> (['minus one', 'zero', 'one', 'two']) -> [-1, 1, 2, 0]
[-100, 45, 96] -> (['minus one zero zero', 'four five', 'nine six']) -> [45, -100, 96]
[11, 12, 13, 134, 135] -> (['one one', 'one two', 'one three', 'one three four', 'one three five']) -> [11, 13, 135, 134, 12]

There's also a script for verifying your results.

Related

Despite the barrage of minor clarifications, nice challenge!

@trichoplax I hope I have clarified the challenge a bit, I updated the Input section.

Looks good. I've deleted all my comments that no longer apply

Why doesn't "one" (pronounced "won") come after two and before zero?

@BenMiller I can't recall if it was you who commented in the sandbox, but that comment gave me deja vu. To answer it here, I contemplated it, but I went with spelling to avoid spelling discussions (e.g. "two" vs "too", "won" or "wan")

So it is actually more "spelling sort" than "pronounciation sort" :-)

bummer. I was hoping they would be sorted by how difficult they are to pronounce...

This challenge really should be renamed, since the sorting here has virtually nothing to do with pronunciation. It would be immensely more complex if it were pronunciation-based (e.g., four might come before five if you sort the monophthong ⟨ɔː⟩ before the diphthong ⟨aɪ⟩, but five before four if you sort a-derived ⟨a⟩ before o-derived ⟨ɔ⟩ – there is, to my knowledge, no established sorting order for pronunciation, neither in IPA nor in any other scheme).

@JanusBahsJacquet you could make another (more difficult) challenge where all numbers had to be sorted by spelling, or define an order for pronunciation. I chose an easier ordering for my challenge as I like to keep my challenges easy enough for everyone to understand and appreciate, while still being fun to golf. I agree that the name isn't perfect, but I chose it because I thought it'd gather some more attention for the challenge.

Do you have to take locale setting into account? Or is this limited to English spelling?

@OleTange this challenge is limited to English only for simplicity and giving everyone an equal chance. I'm not a linguist, but in theory there could be a language where pronunciation order would be equal to regular sorting order, which gives a 1-byte solution to anyone using that locale

@maxb Sorry, I meant: Should it work for any locale? It will still give an equal chance to everyone, but you would have to support all known locales, which would make this task considerably harder.

@OleTange oh, I understand now! That would be considerably harder indeed, but it is not required for this challenge. If you want to make your own challenge, you're very welcome to use this one as inspiration.

Haskell, 57 bytes
import Data.List
sortOn$map(`elemIndex`"54-9176320").show

Try it online!

This is so clean and readable! Definitely the winner in terms of ease of understanding.

Jelly,  15  13 bytes
ṾV€ị“Þ⁽3Z6»µÞ

Try it online!
A monadic link accepting a list of integers which yields a list of integers.
How?
Sorts by the ordinal values of the digits of the integers (where - is a "digit" of -1) converted to strings using the characters at their 1-based & modular index in the magic string "murgeon lix".
The sort is effectively alphabetic where a space is considered less than any letter.
The magic string "murgeon lix" was found by inspecting Jelly's dictionaries used in compression. There are no words of 11 letters which satisfy the requirements (and none of more that would upon de-duplication). since a space sorts before letters the next most obvious choice is a word of length seven followed by a space followed by a word of length three. "murgeon" and "lix" is the only satisfying combination, although without a space others may be possible (e.g. “£Py:ƥ» is "murgeonalix" which works for the same byte-count)
ṾV€ị“Þ⁽3Z6»µÞ - Link: list of integers
            Þ - sort by:
           µ  -   the monadic link: -- i.e. do this for each integer, then sort by that
Ṿ             -     unevaluate  (e.g. -803 -> ['-','8','0','3'])
 V€           -     evaluate each as Jelly code  (e.g. ['-','8','0','3'] -> [-1,8,0,3])
    “Þ⁽3Z6»   -     "murgeon lix" (compression of words in Jelly's dictionary plus a space)
   ị          -     index into (1-indexed & modular) (e.g. [-1,8,0,3] -> "i xr")

Previous @ 15 bytes:
ṾV€ị“¡Zo⁶’Œ?¤µÞ

Here “¡Zo⁶’Œ?¤ finds the first permutation of natural numbers which would reside at the index 21,340,635 when all permutations of the numbers are sorted lexicographically - which is [6,10,9,3,2,8,7,1,5,4,11]. (“¡Zo⁶’ is a base 250 representation of 21340635, while Œ? does the calculation and ¤ groups these instructions together)

Even with the explanation, I don't feel very clever. Awesome solution!

The shorter version is probably also easier to understand!

05AB1E (legacy), 15 bytes
Σε•Koéa₃•'-3ǝsk

Try it online!
Explanation
Σ                 # sort by
 ε                # apply to each
             sk   # index of the element in
  •Koéa₃•         # "85409176320"
         '-3ǝ     # with "-" inserted at index 3

There seems to be a bug in the compressed integer •ĆU‘•.. It adds a newline during the mapping/sorting for whatever reason. Σ•ĆU‘•"54-ÿ"sSk could have been a 15-byte alternative I was working on, if it weren't for that weird bug.. If I change •ĆU‘• to the literal 9176320 it works just fine..

@KevinCruijssen: That is weird. Yours would be 14 with …54-ì even

@KevinCruijssen: You could do Σ•RT‹•Á…54-ìsSk for 15

•t∍ýJ•'-ìÁÁ would also work

Perl 6, 30 bytes
*.sort:{TR/0..9-/a5982176043/}

Try it online!
Port of G B's Ruby solution.
Original 35 byte version
*.sort: (~*).uninames».&{S/\w*.//}

Try it online!
Convert each number to a string, get the Unicode name of each character, strip the first word ("DIGIT" or "HYPHEN"), then sort.

Python 3, 68 bytes 67 bytes 64 bytes
lambda x:sorted(x,key=lambda y:[*map('54-9176320'.find,str(y))])

Uses built-in sorted function with an anonymous lambda for the key. Hard-code the sort order and compare each digit in each value in the input list to its position in the sort order list.
Edit: Saved 1 byte by removing 8 from sort list to take advantage of str.find returning -1 when parameter is not found. Thanks to maxb.
Edit2: Saved 3 bytes by using starred unpacking syntax in a list literal instead of list constructor
Try it online!

Could you remove the first 8 in the string? As Python returns -1 if the substring is not found.

@maxb Good catch. Edited.

Python 2 port is 58: `lambda x:sorted(x,key=lambda y:map('54-9176320'.find,`y`))`

K (ngn/k), 21 20 22 bytes
{x@<"54-9176320"?/:$x}

Try it online!
{ } function with argument x
$ format as strings
"..."?/: find indices of individual characters in the given string (or \$-2^{63}\$ for not found - note that the "8" is missing)
< compute sort-ascending permutation
x@ the argument at those indices

JavaScript (SpiderMonkey), 69 bytes
a=>a.sort((a,b)=>(g=n=>[...n+''].map(c=>':598217604'[c]||3))(a)>g(b))

Try it online!

It looks like you can remove the +'', seeing as you're taking input as an array of strings.

@Shaggy I'm not taking strings anymore, as I'm not sure if that's allowed here.

Ah ... You're right. That's gonna add a couple of bytes to my solution.

Pyth, 17 16 bytes
oxL"54-9176320"`

Try it online here, or verify all the test cases at once here.
oxL"54-9176320"`NQ   Implicit: Q=eval(input())
                     Trailing N, Q inferred
o                Q   Order the elements of Q, as N, using...
               `N      Convert N to string
 xL                    Get the index of each character of that string...
   "54-9176320"        ... in the lookup ordering
                       (if character missing, returns -1, so 8 is still sorted before 5)

Saved 1 byte thanks to @ngn and their K answer, by omitting 8 from the start of the dictionary string

Japt, 19 bytes
ñ_s ®n"54-9176320

Try it

Save 2 bytes thanks to ETHproductions.

Nice solution! Input as a list of strings is not allowed unfortunately.

You can save some by abusing S.n(s): ñ_s ®n"54-9176320 (apparently S.n(s) is exactly the same as s.b(S) for S of length 1, except it returns 0 in place of -1)

Nice trick, @ETHproductions, thanks :) I'll have to remember that one for the future.

Retina 0.8.2, 36 bytes
T`-d`3:598217604
O`
T`3:598217604`-d

Try it online! Link includes test suite. Explanation:
T`-d`3:598217604

Translate the minus sign and digits to their position in pronunciation order, using : for 10th position.
O`

Sort in pronunciation order.
T`3:598217604`-d

Translate the order back to the original minus sign and digits.

Ruby, 50 bytes
->a{a.sort_by{|x|x.to_s.tr('0-9-','a5982176043')}}

Try it online!

Java (JDK 10), 123 bytes
l->l.sort(java.util.Comparator.comparing(n->{var r="";for(var c:(""+n).split(""))r+=11+"54-9176320".indexOf(c);return r;}))

Try it online!
This is a naive Java implementation. Should be much golfable.
Credits

3 bytes saved thanks to Kevin Cruijssen

Changing the .chars-IntStream and .reduce to a regular loop saves 2 bytes: n->{var r="";for(var c:(""+n).split(""))r+=10+"854-9176320".indexOf(c);return r;}. In addition, one more byte can be saved by changing 10+"85 to 20+"5, since the .indexOf for digit 8 would then result in -1. Try it online 123 bytes

R, 58 bytes
function(x)x[order(mapply(chartr,"-0-9","dkfjicbhgae",x))]

Try it online!
Input is a list of numbers which is implicitly converted as string using chartr. order then uses lexigographic order to retrieve the order by which the original list should be sorted.

C++, 353 bytes
This is kind of a comedy entry, but I was wasting time and wrote it, so I can't not post it... Enjoy a chuckle, and let me know if there are any space-savers I missed!
#include<algorithm>
#include<iostream>
#include<iterator>
#include<numeric>
#include<string>
using namespace std;auto f(int i){auto s=to_string(i);for(auto&c:s)c='A'+"854-9176320"s.find(c);return s;}int main(){int a[100];auto b=begin(a);auto e=end(a);iota(b,e,-50);sort(b,e,[](int l,int r){return f(l)<f(r);});copy(b,e,ostream_iterator<int>(cout," "));}

Output:

8 5 4 48 45 44 49 41 47 46 43 42 40 -8 -5 -50 -4 -48 -45 -44 -49 -41 -47 -46 -43 -42 -40 -9 -1 -18 -15 -14 -19 -11 -17 -16 -13 -12 -10 -7 -6 -3 -38 -35 -34 -39 -31 -37 -36 -33 -32 -30 -2 -28 -25 -24 -29 -21 -27 -26 -23 -22 -20 9 1 18 15 14 19 11 17 16 13 12 10 7 6 3 38 35 34 39 31 37 36 33 32 30 2 28 25 24 29 21 27 26 23 22 20 0

I see you also live by the motto "if I don't press enter there are fewer lines to debug"

Hey, I can't afford frivolous whitespace in this language! It's funny to have to do this, seeing as the rest of the time, few things make me as angry as opening up others' code, who apparently think writing a horrifying monolithic wall will make them seem smarter, and/or are actively docked pay for every newline they type.

Hello! Squeezed your solution to 195 characters

@MaxYekhlakov Cool, thanks for pondering it! I realise after reading around a bit more; it seems that I needn't necessarily have provided a full compilable program, but instead only the functions that would process the specified input and output. D'oh!

Mathematica, 68 bytes
SortBy[If[# < 0,"m ",""]<>StringRiffle@IntegerName@IntegerDigits@#&]

Function. Takes a list of integers as input and returns the sorted list as output. Just separates the digits of each number with IntegerDigits, converts each digit to "zero", "one", etc., with IntegerName, converts the list into a space-separated string with StringRiffle, prepends an "m " if the number is negative, and sorts based on this string. Indeed, this was the shortest approach I can find, since Mathematica only natively uses lexicographic sorting for lists of the same length; thus, an approach based on 854-9176320 ends up taking more bytes since string functions are so expensive.

Always trust mathematica to have a combination of builtins. Clever solution!

JavaScript (SpiderMonkey), 87 73 bytes
a=>a.sort((p,q,F=b=>[...""+b].map(x=>"54-9176320".search(x)))=>F(p)>F(q))

Try it online!
Thanks @Arnauld for telling that the sort in SpiderMonkey is stable, so the ||-(F(q)>F(p)) part can finally be dropped.

Red, 114 bytes
func[n][g: func[a][collect[foreach c form a[keep index? find"854-9176320"c]]]sort/compare n func[x y][(g x)< g y]]

Try it online!
More readable:
f: func [ n ] [
    g: func [ a ] [
        collect [
            foreach c form a [
                keep index? find "854-9176320" c
            ]
        ]
    ]
    sort/compare n func [ x y ] [ (g x) < g y ]
]

05AB1E, 15 14 13 bytes
Σ•t∍ýJ•(ÁÁsSk

-1 byte thanks to @Emigna.
-1 byte thanks to @ovs.
Try it online or verify all test cases.
Explanation:
Σ              # Sort by:
 •t∍ýJ•        #  Push compressed integer 917632054
       (       #  Negate it: -917632054
        ÁÁ     #  Rotate it twice towards the right: "54-9176320"
          s    #  Swap so the current number to sort is at the top of the stack
           S   #  Convert it to a list of characters
            k  #  Check for each its index in the string (resulting in -1 for '8')

See this 05AB1E tip of mine (section How to compress large integers) to understand why •t∍ýJ• is 917632054.

13 bytes by rotating -917632064 instead of prepending a string.

Nim, 110 109 105 103 bytes
import algorithm,sequtils,strutils
func p[S](n:S):S=n.sortedByIt join mapIt($it,$"54-9176320".find(it))

Try it online!
For some reason, Nim can't compare seqs, so I had to turn the results into a string, which cost quite a lot of bytes.


text:
Self Scoring Program
We have a challenge to output your own score, but it seems like all the answers there just hardcode the output and that's boring1.  So lets have a new challenge.  Your program must output its own length in bytes followed by the string " bytes", but in order to prevent hardcoded solutions if we reduce its size by removing any one byte, the new program must also output it's new byte count, still followed by " bytes".  Output does not need to be case sensitive. You may also choose to output a trailing newline.
Your answers will be scored in bytes with fewer bytes being better.

1: I actually like some of the answers there.

Maybe you could change the name of the challenge to "self scoring modifiable program" or something similar.

Can you use complied languages or only interpreted?

@Logern You can use either.

Argh. I spent half an hour making a Hexagony solution, but when I went to test it, removing the byte made the hexagon shrink! :(

It looks like that there won't be any problem with 1 bytes.

@user202729 I'm not sure I understand what you mean.  Could you elaborate.

@WW What I mean is "1 bytes is technically wrong grammar, but assuming languages don't have a built-in to output the string "bytes" in <= 2 bytes, the program will be longer than 3 bytes, so it doesn't matter" -- it doesn't matter anyway.

Backhand, 40 36 29 bytes
vv""sseettyybb  ""jjHHOO]

Try it online! Verification!
When in doubt, double up on everything. This uses Backhand's ability to move more than one step at a time to implement the redundancy. The unprintables all have the byte value 28.
Explanation:
Non-irradiated program:
v       Reduce step count to 2
  "    Start string literal
    s e t y b        Push the " bytes" part of the output
                  " Push 28 twice and end the string literal
                       j    Jump to the 28th position (0 indexed)
                             ]   Increment the 28 to 29
                           O     Print the 29
                         H       Halt and output the entire stack

Irradiated program:
If any character is deleted, every character after that is shifted down.
vv"sseettyybb
v " s e t y b     The same instructions are still executed

However, instead of jumping to the ], it instead reflects off the end of the program and lands on the O instead.
                             v  28th character (0 indexed)
vv""sseettyybb       ""jjHHOO]
v""sseettyybb       ""jjHHOO]OOHHjj"".....
                             ^ 28th character, reflecting off the end of the code

Runic Enchantments, 47 bytes
>>yyLL     @"setyb 64"/
"47 bytes"@"setyb 64"L\

Try it online!
Which is more or less a port of my Geiger Counter answer, but with different output (which is, itself, a port of a Klein answer).
>>yyLL is required for Runic to generate (at least) one IP, merge two IPS, and reflect back to the left, so that all variations result in a single left-moving IP. Could be replaced by yy<< but it doesn't save any bytes.
The reflectors on the right force the IP to the lower left string, so the removal of top right one of them allows the IP into the top right string. Removing a byte anywhere else along the top line adjusts the top reflector to sit above the L (allowing the program into the lower right). The removal of a byte along the bottom adjusts that reflector (or removes it) so that the last character gets implicitly filled with a space, which allows the IP to bounce off both sides of the top right reflector and into the top right string.
The excess spaces are disappointing, though. But all attempts to reduce them have resulted in either larger programs, same size programs, or programs that are not 100% radiation proof. Both the Klein and ><> answers here use features not available in Runic.

><>, 43 39 bytes
||vn-{"' bytes"-10/
 o>o<"38 bytes"[0/0

Try it online! Verification!
In the un-irradiated program, we add 0 to the ' (39), and in the irradiated program we skip the 0 and add -1 to it instead. If something is removed from the top row, we shift to the bottom row instead and just output 38 bytes.

Klein 000, 41 bytes
<<@"setyb "$"4"+"0"/
..@"setyb 04"(....<1

Try it online! JoKing's Verifier
I think this answer is similar to JoKing's ><> answer, but I don't read ><> so I can't be sure.
There are 4 different types of byte removals here

A byte is removed from the first line before /.  In this case the slash is effectively moved left one space, deflecting it onto the bottom line and preventing the modified part of the code from being executed.  This causes us to run the code ("40 bytes"@, which outputs 40 bytes.
The first / is removed from the first line.  In this case we run the code "0"+"4"$" bytes"@, which is a convoluted way or printing 40 bytes.
The newline is removed. This makes us start from the end of the second line and the resulting code (with noops removed) is 1("40 bytes"@, which just prints 40 bytes.
A byte from the last line is removed.  This causes the 1 at the end of the first line to be moved left and prevents it from being added to the stack when the pointed is deflected by /.  The code "0"+ for that reason pushes 0 instead of 1, the rest of the code turns the 0 into 40 bytes.

Klein 001, 41 bytes
\("40 bytes"@......1
..@"setyb "$"4"+"0"/

Try it online! JoKing's Verifier
Here's an answer using a different topology.  It's the same size but I think there is room for improvement.

37 bytes in 200

Hexagony, 71 bytes
//.........||.>e;s;@..\;t;y;b<>}F"+!P0;/|/F!P0$@;<...t;ye;bs/.........)

Try it online! Verification!
I spent way too long trying to get this into a size 5 hexagon, but I had to settle for a subpar size 6 instead :(.
Expanded:
      / / . . . .
     . . . . . | |
    . > e ; s ; @ .
   . \ ; t ; y ; b <
  > } F " + ! P 0 ; /
 | / F ! P 0 $ @ ; < .
  . . t ; y e ; b s /
   . . . . . . . . .
    ) . . . . . . .
     . . . . . . .
      . . . . . .

I initially made this with the ) one row lower, but it turns out that's exactly where the divide between size 5 and size 6 hexagons are. This means when a byte is removed, the size all shifts down and ruins the pathways. I'm definitely sure that a size 5 is possible.

If I'm understanding this correctly, can't you put the ) a row lower and then just put a no-op after it so it is a size 6 hexagon?

@EdgyNerd If you put a no-op after it than it can be removed without affecting the program