# Questions tagged [sorting]

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

312 questions
Filter by
Sorted by
Tagged with
81 views

### Nonrepetitive representation of a group of lists (with sharing members)

Background: Lets first construct a square graph (the ha and second points define to implement periodic boundary condition): ...
215 views

### List of tuples without duplicates & repeated values [duplicate]

Given some number nand set of values vals, I want to obtain all the tuples/permutations of size ...
41 views

### Confusion about the sorting function

The following one-dimensional array can be sorted well: Sort[{Infinity, 10, 2, 1, -4}, #1 < #2 &] But the following two-dimensional array cannot sort the <...
104 views

### Ordering a list of rules by its 4 last elements of LHS

I have a list of rules such as ...
54 views

### Sort a nested Association by another Association

I have a nested association of numerous pixel values sorted by sample date (e.g. 20190422C) and futher by a strain percentage (e.g. 0, 30, 50). I want to sort it even further using and Association of ...
96 views

### How do you reorder a sublist of strings, within a list?

I have a list that looks like this: ...
215 views

### Ordering Problem With VoronoiMesh

Imagine I want to model 2D cells moving in a tissue. Consider, as an example, Lloyd's relaxation algorithm. Using VoronoiMesh I'm able to mimic some cell movement. ...
214 views

### Best way to insert element into an ordered list at the correct position?

Suppose I have an ordered list orderedList and I want to write some code that will involve regularly inserting new elements into ...
26 views

### Arranging terms by the values of numerical coefficients

I have a list with elements of the form myList = {c1 F1, c2 F2, c3 F3, ...} where c1, c2, ... are explicitly integers, and ...
57 views

### Resorting nested list A according to nested list B

How can sort nested list according to each other? e.g. I have the following list: ...
109 views

### How to group together numbers in a list by the value of their tens digit?

The line Table[Prime[n],{n,1000}] produces the list of first 1000 primes. Given this list how can the values be grouped by the values of their tens digit? i.e. how ...
105 views

### Sorting exponential numbers

I want to sort some exponential numbers like {2^2,3^3,4^2} and i want The result {2^2,4^2,3^3}. But Mathematica Sort function apply's the powers in the result and return's {4,16,27}. How can i get the ...
33 views

### How to sort a distance matrix in mathematica

I have the following code which results in the heatmap shown: ...
72 views

### Unique matrix ID and fast checking

I have the following problem : I have a programm which can generate a lot of 3x3 matrices whose elements take integer values in [-3;3], example :{{1,2,3},{-3,0,-2},{1,1,1}}. Each time my programm ...
118 views

### Sorting a sparse matrix so that non-empty rows place on top

I have a $n$ by $2$ matrix that has binary values(0,1) as its entry. For example m={{1,Null},{Null,0},{Null,Null},{0,0},{1,0},{0,1}} I want it to be sorted ...
48 views

### Sort Stocks by MarketCap

If I correctly understand, here I have all the existing companies listed in every market and identified by each real name: ...
47 views

### Why doesn't Sort work in this case ? (Only numerical values)

Context I want to interpolate a complicated symmetric function f of 2 variables x and y defined by some numerical integral involving Bessel functions. Since computing the integral itself is a bit ...
50 views

### Help in modifying my code

In my code, I want to plot (Dis[t]). The problem is some functions containing in the code do not work well if there are variables in the form of symbols, such as "Sort" "NMaximize" functions. I want ...
28 views

### Preventing mathematica from evaluating “Sort” function, except in the case of numerical values

Say I want to sort the eigenvalues E1, E2, and E3 using "Greater" as following: {EA, EB} = Sort[{Chop[E1], Chop[E2], Chop[E3]}, Greater][[{1, 2}]]; But I want ...
53 views

### “Greater” function gives me wrong order

When I try to sort the eigenvalues of the matrix (Rho) the results seems to be in the wrong order What is wrong with my code? ...
27 views

### Adding up a list of rules

Here's the problem: I take a count of a count, so that I end up with a list in this format: Table[Counts@Counts@Join[dKm[[i]], Pick[data1, ccKMedoid, i]], {i, 5}] ...
42 views

### Does Mathematica have an order relationship for lists, or a general ordering relation?

{1, 2} < {3, 4} doesn't seem to work, but Sort[{{3, 4}, {1, 2}}] yields {{1, 2}, {3, 4}}. ...
218 views

68 views

### Why do these commands give different answers?

I'm using v12 ...