# Tagged Questions

Questions on the sorting/ordering functions of Mathematica (Sort, SortBy, Ordering, etc.).

26 views

### Large matrix: Finding eigenvalues and ordering it with respec to the highest coefficient of its eigenvectors

I have a 900x900 matrix to diagonalize. After diagonalizing it, I have a table of eigenvalues and eigenvectors. For convenience, I start with 3x3 matrix. ...
37 views

### Mathematica, stop sorting my output! [on hold]

I'm trying to get some output from Mathematica / WolframAlpha, but it's coming out in a useless format. Mathematica is, for some reason, sorting my output. Below is the output from my function and ...
37 views

### Sorting Ordered List of Words by First Letter

I am trying to sort an ordered list of the most common Arabic words. I want to create sublists of words according to their first letter while maintaining the order of the original list. Here's an ...
24 views

### How To Sort BarChart Data Based On the Selected Column

This sample code works fine for the category of StarData selected. What I would like to do is sort the data based on which BarChart is selected. ...
79 views

### Sorting matrices by their norms

I have a matrices A and their Norms(Matrices B). I want to rank Matrices A based on their Norms. From smallest to highest Norm
50 views

### Sorting Data by Differences between Columns

In Band Structure calculations one gets rather extensive data of Energy Values (Eigenvalues) and the associated Eigenvectors out of the solution of an Eigenequation of e.g. the form H.$\psi$=E.$\psi$. ...
84 views

### Double Sorting a Matrix

Say I have two matrices {{0, 1, 2, 2}, {2, 1, 0, 2}} and {{2, 1, 0, 2}, {2, 1, 2, 0}} I then sort by the first row ...
155 views

### How to sort eigenvalues?

I am trying to find Eigenvalues to a 12x12 Matrix ($H$) dependent on two variables $x$ and $y$. Later I want to do a 3D plot of one eigenvalue ($E$) over $x$ and $y$. An analytical solution is not ...
66 views

### Order of importing data from files

I have many text files numbered from 1 to 1 million in numerical order. Within each text file is 5 columns of data (TAB spaced) with many rows. I effectively want to take the minimum value from each ...
28 views

### How to customize the order of leaf labels in a dendrogram plot?

Take the following simple case as an example: Needs["HierarchicalClustering"] SeedRandom[99]; Sort@RandomInteger[99, {10}] gives {2, 7, 22, 34, 42, 58, 60, ...
344 views

### Retaining and reusing a one-to-one mapping from a sort

Imagine I sort the elements of an array $Q$ by some means. Perhaps I sort strictly by the elements in the first column, perhaps I use SortBy[...] to sequentially sort by the elements in successive ...
179 views

### Sort by returning positions [duplicate]

How can I computationally efficiently sort a list so as to return the positions and not the actual values at those positions (which SortBy does)?
339 views

### Matching the order of a master list of lists from a random list of lists

Using Mathematica 9, I have 2 lists of lists one master with dimensions {300, 6}. The second is some random order but has the same first ...
45 views

### Applying multiple functions to a single column in a table

I've seen similar questions, but I'm having trouble applying solutions found there to my situation. My sorting function: ...
55 views

### Sorting the words of a phrase by defined variables/associations

Is it possible to change the word order of a phrase by creating a list of possible values/variables and using the Sort function? I want a specific word order always. $(a>b>c>d)$ But the ...
138 views

MWE: ...
219 views

### Use of Sort with custom functions

As mentionned in the topic title, I try to apply my own sorting functions to a set of elements via the Sort command. I make here a quick presentation of the subject before. 1) Method We will ...
4k views

### Sort data after specific ordering (ascending/descending) in multiple columns

I have some data: data={{"a", 1, 1}, {"a", 1, 2}, {"a", 1, 3}, {"c", 2, 1}, {"b", 2, 2}, {"b", 2, 3}, {"c", 3, 1}, {"a", 3, 2}, {"a", 3, 3}} When I ...
85 views

### Plotting eigenvalues smoothly

I am trying to plot how the eigenvalues of a matrix change by changing a given a parameter t. Of course the ordering of the eigenvalues does not matter mathematically but it does when I want to make ...
292 views

### How to make a better Sort` in my case

I have some file names like this: ...
1k views

### How to plot several functions without jumping? (multiple eigenvalues of a system as functions of 2 parameters)

I've been working on this research problem for months with some success by no global/proper solution to the problem. So I have square, Hermitian matrices of various sizes ($8,20,38$ dimensions) with ...
31 views

### How to sort data as in Excel? [duplicate]

How to create a program in Mathematica to sort data (table with several variables) by different variable, by clicking the name of the variable, much like in Excel with freeze pane?
522 views

### Reproducing a ranking function that behaves like Excel's RANK

I tried to find a function or expression in Mathematica that produces the same output as the RANK function in Excel (see its description here), but unfortunately I ...
86 views

### Problem with Custom Sort/Split/Gather

Please help me Sort/Split/Gather/Group(by) a set of symbolic expressions! (extreme TL;DR at bottom) I have a set of symbols (which represent 2-vectors in a plane, ultimately) and I want to sort/...
75 views

...
71 views

### How to check a clockwise direction for a list of point [closed]

Suppose that we have a list of points and we need to order them in clockwise direction by starting from a special point. I implemented this code to order them but I need to detect if it is ordered in ...
805 views

### Ordering problem

Let's look at the following example. Ordering[{0, 20 Sqrt[5], 40 Sqrt[5], 20 Sqrt[5], 20 Sqrt[10]} // N] gives the right answer ...
333 views

### GatherBy/SplitBy and Sort a list

So let's say I want to group a list of points based on their distance from the origin. I would do something like: ...
91 views

### Role of Accuracy in numerical evaluations, SplitBy vs GatherBy

This is a follow-up question to this question. I generated a list by substituting the results of a solve[] routine and set: ...
65 views

### Can't sort my list numerically for larger numbers than 10 e.g. 1,10,100,2 [duplicate]

I want my files names in real numerical order so 1,2,3,10,12. However it is currently putting them in order like so: 1,10,12,2,3 Input: ...
244 views

### What is wrong with my user-defined ordering function?

I've defined ordering function: myOrderingFunction[arg1_, arg2_] which always return True or ...
106 views

### Change Contour Plot Overlap Ordering

I have a contour plot for which I have selected a finite set of contours. However, the contours overlap in some places and I would like to reverse the order in which they are drawn. In other words,...
296 views

### Negative power instead of fraction [duplicate]

Solve returns a solution in the form {{ x -> y / a^2 + y^2 / a^7 }}. Since I want to process the input (with another program) in terms of Laurent polynomials, I ...
62 views

### Finding correct combination of functions

I am trying to write code where I have an array $S$ or numbers in any order [5,4,2,1,....] Then I have a specific set of functions that I can write. ...
423 views

### Unexpected result {“.a”, “co”, “.m”} from Sort[{“.m”, “.a”, “co”}]

I came across the following situation: Evaluating Sort[{".m", ".a", "co"}] Results in {".a", "co", ".m"} I wondering: ...
64 views

### Unexpected result from Sort with symbolic values

I think Sort should be able to sort symbolic values that are reducible to numerical values, but this example seems to get a wrong answer (here is a simplified ...
56 views

### Select Only Positive Values and Prepend a Title

I have the following list: ...
109 views

### How to order a list to match the order of another list?

How can I order a list to match the order of anoter list ? For example: Suppose I have the lists x = {3, 1, 5, 7} and ...
78 views

### SortBy behaving strangely with missing data

I'm trying to create a grid that shows the largest data value from a list. What I have mostly works- the problem comes when there is missing data. You can't really tell here, but all of the ...
457 views

### How to sort list of mixed types of elements with each type a specified canonical order?

For example, here is a list {{1, "u"}, {6, "d"}, {3, "u"}, {4, "d"}, {2, "u"}, {5, "u"}, {3, "d"}, {1, "d"}, {4, "u"}, {2, "d"}, {5, "d"}, {6, "u"}} The ...
314 views

### Wolfram Language symbols by their Ranks

I'd like to get the top 50, the bottom 50 and an ordered list of all Wolfram Language symbols based on their "Ranks". With ...
52 views

### Sorting in descending order of list [closed]

I have a list m = {{a, 20}, {b, 10}, {c, 50}, {d, 5}, {e, 100}} and I want to apply Sort on this in descending order on ...
228 views

### Exercise using Sort

I have to order the following list according to the sum of the powers of each element of the list, using the function Sort. ...
118 views

### Sorting and keeping the main format of list numbers [duplicate]

I have a list with these elements: list={1/2 (1 + Sqrt[5]), 1, 1, 1/2 (1 - Sqrt[5]), 0}; I want to sort them with ...
126 views

### How do I use Subgraph to sample the $n$ vertices of a graph with the greatest connectivity?

Let $G$ be an arbitrary graph with some number of vertices $||V||$ and some number of edges $||E||$. We can use Subgraph to generate, well, a subgraph of ...
439 views

### Position function not always returning an answer even with no apparent problems

I'm having some problems with Position. Sometimes it will give an empty list instead of the actual position of the element I am looking for when that element is ...
152 views

### Complement[] changes order of elements?

Consider this example: Complement[{a, y, c, d, e}, {a, c}, {d}] (*{e, y}*) However, I was expecting the result to be: ...
61 views

### Sort a list of derivatives

I have a list of variables, both constant and functions of an independent variable, including derivatives. I'd like to sort these by the variable name, rather than the derivative order. For example, ...