R, 175 169169 155 bytes
\(v){s=sort(v);g=matrixg=matrix(,6,6);C=T
for(is in 36:1sort(v,T)){
T>1&&g[T-1,C]==s[i]|C>1&&g[TC]==s|C>1&&g[T,C-1]==s[i]&&return1]==s&&return()
g[T,C]=s[i];T=T+1;C=CC]=s;T=T+1;C=C-1
if(T>6|C<1){C=T+C;T=1;C>6&&{T=T+C-6;C=6}}}
g}
Attempt This Online!Attempt This Online!
\(v) { # v = vector of 36 numbers to arrange in 6x6 grid
sg = sortmatrix(v, 6, 6) # create 6x6 grid initialized #with sortNA vvalues
in ascendingC order= (reversedT loop handles descending)
g = matrix(, 6, 6) # create 6x6 grid initialized with NA# C = column index (shorterstarts thanas 0TRUE = 1)
C = T # C = column index, # T = row index (both start asimplicitly TRUE = 1, will be reassigned)
for(is in 36:1sort(v, T)) { # iterate through v #sorted iteratein backwardsdescending throughorder
indices # sort(effectivelyv, descendingT) ordermeans sort(v, decreasing=TRUE)
# s takes each sorted value directly
T > 1 && # if not in first row AND
g[T-1, C] == s[i]s # value directly above equals current value (not strictly descending)
| # OR
C > 1 && # if not in first column AND
g[T, C-1] == s[i]s # value directly to left equals current value (not strictly descending)
&& return() # then return NULL (impossibleno solution - not strictly descending)
g[T, C] = s[i]s # place current value in grid at position (T, C)
T = T + 1 # move down one row (diagonal movementfilling pattern)
C = C - 1 # move left one column (diagonal movementfilling pattern)
if(T > 6 | C < 1) { # if we've gone offmoved theoutside grid boundaries:
C = T + C # # calculate next diagonal'scalculate starting column for next diagonal
T = 1 # reset to first row
C > 6 && # if columncalculated iscolumn beyondexceeds grid width:
{T = T + C - 6 # adjustshift row down by overflow amount
C = 6} # set column to lastrightmost columnposition (6)
}
}
g # return the completed grid (if possible)
}