# Tag Info

9

This is due to Sort on lists sorting by the size of the sub-list first, and only applying lexicographic sort for equal-size lists. This is in fact documented. Based on this observation, here is one possibility: ClearAll[lexicographicListSort] lexicographicListSort[lst_List] := Module[{lengths = Length /@ lst, ord}, ord = Ordering @ PadRight[lst, ...

8

This is not a complete answer, but it's too long for a comment. It doesn't completely work, but perhaps it might inspire other answers. The idea is to use graph theory and flows. I shall just look at the 3x3 case. First we construct a graph of 9 source nodes and 9 sink nodes. The source nodes flow costlessly straight into the sink nodes, and the sink ...

7

You basically want to permute the elements of the list among some specified set of permutations, and find the ordering of the list among these permutations that is canonically "first". The set of permutations you're interested in is a subgroup of the permutation group $S_n$, generated by two generators, one of which rotates all elements one position to the ...

3

Let me start by generating a Dataset from your JSON string. Note that I adjusted your expressions a little. jsonRules = "result" /. ImportString[jsonResult, "JSON"]; originalds = Dataset[Association @@@ jsonRules] Rearranging the columns can be accomplished without a helper function. Instead, we pick columns in originalds to generate a new data set with ...

1

Using Complement on two lists could be used as follows: Complement[l1, l2] == {} True If you have more than one list, for example, l1 = {a, b, c}; l2 = {b, c, a}; l3 = {c, b, z}; you could also implement it with Tuples and compare the lists pairwise: ((Complement @@ #) == {}) & /@ Tuples[{l1, l2, l3}, 2] {True, True, False, True, True, ...

Only top voted, non community-wiki answers of a minimum length are eligible