Hot answers tagged


What I think you are asking for can be achieved by 1) pairing up the values in the two rows (using Transpose) 2) Sorting by the First value in each pair using SortBy 3) Unpairing, again using Transpose. Specifically lists = {{2, 1, 0, 2}, {2, 1, 2, 0}} SortBy[Transpose[lists], First] // Transpose


I think this should be marked as a duplicate of: Retaining and reusing a one-to-one mapping from a sort The method Jason posted is not equivalent to SortBy unless one is using the stable form, because no tie-breaking using the original expression is performed. Consider: a = {{1, 7, 0}, {1, 4}, {1, 2}, {2}}; b = SortBy[a, First] Ordering[First /@ a] ...


Make a list of your matrices, called myMatrices, and then: SortBy[myMatrices, -Norm[#]&] or Reverse[SortBy[myMatrices, Norm]


Eigenvalues are ordered by their magnitude in general. If you want to preserve the order all over the region, the only way (as much I know) is to try to get an analytical expression. For example consider this simple matrix H[x_, y_] = {{0, Cos[x] + Cos[y]}, {Cos[x] + Cos[y], 0}} If I go with analytical expression ev = Eigenvalues[H[x,y]]; Plot3D[...


The problem here stems from the filenames being in alphabetical order. If you separate the numbers from the ".txt" suffix with StringSplit, you can use ToExpression to get Mathematica to treat them as numbers and put them in numerical order. Then use Ordering to put the original list of filenames in the same order as the list of numbers. filelist = {"1.dat"...

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