# Questions tagged [sorting]

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

15 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
110 views

### What do the InternalCompare* functions do?

As part of looking at this question I dug into Names["Internal*Compare*"] and ended up with: ...
106 views

### Dataset row position changed by GroupBy in 11.0.1

Bug introduced in 11.0.0 and persisting through 11.0.1 or later In 10.4.1 and previous versions then using GroupBy in a Dataset ...
94 views

### How do I reassign the ordering of symbols in a polynomial expression?

I have a big polynomial expression, like this: ...
45 views

### SortBy without final cannonical ordering

How can I SortBy a list without final cannonical ordering? E.g. SortBy[{9, 1, 2, 5, 3, 7}, # Boole[# >= 6] & ] returns <...
95 views

### dynamic binary search

Suppose I have a time series of values $v_1, \dotsc, v_n, \dots,$ (think of the data as being generated by repeated function calls, like a Python generator, or being captured in real time) and I want ...
91 views

### how to sort an expression with descending coefficients?

I have an expression for example psi = 0.24 FF1 FF2 FF3[-1] + 0.23 FF1 FF2 FF3 + 0.5 FF1 FF2 FF3 + 0.25 FF1 FF2 FF3 I wonder how ...
53 views

### In what order does Combinatorica's SetPartitions function list the partitions of a set?

For example, Needs["Combinatorica`"] n = 4; partitions = SetPartitions[Range[n]]; Table[Print[partitions[[i]]], {i, 1, BellB[n]}] generates ...
82 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. ...
274 views

### Collision detection algorithm (discrete) with sweep and prune algorithm for periodic boundary conditions

EDIT: Question Updated with solution approach, but solution much slower than original implementation. Any ideas to speed up implementation? In the discussion on collision detection (see here) I asked ...
83 views

### How do I reassign canonical ordering of special expressions?

1. Default behavior of Sort Note: this peculiarity is described in a comment to a related question at StackOverflow but I think it's worth restating here at mma.sx. It is estabilished in ...
52 views

### Using SortBy on a list of a list of a list

I have quite a typical physics problem at hand, I want the eigenvalues and -vectors of a Hamiltonian matrix. I have a parameter s, which I vary in 1000 steps and for each step I want my H matrix to be ...
51 views

### SortBy not working in a delayed output

I have a table of large number of elements, each with three elements, say A = {{a, b, c}, {e, f, g}...}. I am using the function ...
48 views

### How can I get a specific ordering in the matrix and the results of a system linear equations?

I have a linear system of 22 equations and variables. When I create the matrix form it sorts the coefficients on the first row (X1, X10, X11, ...) This ordering repeats for all columns and all the ...