# Vocabulary/slashco

>>
<< ` `
Down to: Dyad ` `
Back to: Vocabulary
Thru to: Dictionary

`/: y`Grade Up Conjunction

`\: y`Grade Down Conjunction

Rank Infinity *-- operates on x and y as a whole, by items of y --*
WHY IS THIS IMPORTANT?

The permutation
that sorts the items of `y` into ascending (`/:`) or descending (`\:`) order (numerical or lexicographical)

] Wk=: ;:'Su Mo Tu We Th Fr Sa' +--+--+--+--+--+--+--+ |Su|Mo|Tu|We|Th|Fr|Sa| +--+--+--+--+--+--+--+ ] p=: /: Wk 5 1 6 0 4 2 3 p { Wk +--+--+--+--+--+--+--+ |Fr|Mo|Sa|Su|Th|Tu|We| +--+--+--+--+--+--+--+ ] Wko=: > Wk Su Mo Tu We Th Fr Sa p { Wko NB. also works with unboxed list Fr Mo Sa Su Th Tu We

### Common uses

Invert the permutation `q`

Note that `p{q` is the *permutation product* of permutations `p` and `q`

] q=: 10?10 8 7 6 9 5 2 0 4 1 3 ] p=: /:q 6 8 5 9 7 4 2 1 0 3 p{q 0 1 2 3 4 5 6 7 8 9

### Details

1. The permutations (`/: y`) and (`\: y`) produce a stable sort (identical keys stay in order).

2. Grading uses intolerant comparison.

3. Any array can be ordered. The first atom in a row is the most significant for ordering purposes; any item of rank higher than 1 is flattened into a list before ordering.

- Characters are ordered according to the Unicode collating sequence. (For bytes, this is the same as the ordering given by
`a.`). - Symbols are ordered according to the order of the character lists they represent (if one string is a prefix of the other, the shorter string comes first)
- Complex values are ordered on real part first, then imaginary part.

Boxes are ordered according to their contents.

The order of priority for ordering-up is:

- Type: numeric or empty, symbol, character (byte or unicode), and boxed, are so ordered
- Rank: lower comes before higher
- Values: compared after padding with fills to the same shape

### Oddities

1. Boxed symbols are ordered by symbol index, which has no relationship to the value of the symbol.

### Use These Combinations

Combinations using `/: y` that have exceptionally good performance include:

**What it does****Type;**

**Precisions;**

Ranks**Syntax****Variants;**

**Restrictions****Benefits;**

**Bug Warnings**Find ordinal numbers of `y`(the relative rank of each item of`y`in the sort order`/:@/: y`note `\:`is**not**specialbetter than `/:^:2 y`Find the index of the `x`th-largest value of`y``x`is a Boolean or integer atom,`y`is an integer or floating-point list`x ({ /:) y`**not**`\:`Partitions `y`using a randomly-selected pivot, so time and space results are variable, even for unchanging arguments

`x /: y``y /: y`Sort Up (Using) Conjunction

`x \: y``y \: y`Sort Down (Using) Conjunction

Rank Infinity *-- operates on x and y as a whole, by items --*
WHY IS THIS IMPORTANT?

Sorts `x` using the order given by `y`.

i. e. applies to list `x` the permutation
that sorts list `y` into ascending (`/:`) or descending (`\:`) order (whether numerical or lexicographical).
Formally, (`x /: y` is (`(/: y) { x`).

If `x` and `y` are the same, the noun is sorted into order

Wk=: ;:'Su Mo Tu We Th Fr Sa' NB. As defined above (100+i.7) /: Wk 105 101 106 100 104 102 103

### Common uses

1. Sort a list `y`

sort=: /:~ NB. (/:~ y) is the same as: (y /: y) sort Wk +--+--+--+--+--+--+--+ |Fr|Mo|Sa|Su|Th|Tu|We| +--+--+--+--+--+--+--+

**Note:**
Verb `sort_z_` is defined in `stdlib.ijs` as

sort=: /:~ :/:

`sort` is a

- Standard Library word(s) residing in the 'z'-locale.
- Defined in the factory script
`stdlib.ijs`. - View definition(s) by entering in the J session:
`open'stdlib'`

This uses Monad-Dyad (`:`) to define two separate verbs (`/:~`) and (`/:`)
for monadic and dyadic usage of the verb: `sort`.

2. Find the *ordinal number* of each item of `y`, that is, the position each item would have if the array were sorted.

/:@/: 3 1 4 1 5 9 2 0 3 1 4 5

### Details

1. If `x` is an atom, `x /: y` is a one-atom list.

**Except** when `x` and `y` are equal Booleans. Then the result is an atom. Also see below.

2. Sorting uses intolerant comparison.

3. `y` may have fewer items than `x`. The result is (`(/: y) { x`).

### Oddities

1. In 32-bit J, if `x` and `y` are equal Booleans (i. e. (`0/:0` , `1/:1` , `/:~0` , or `/:~1`), the result is Boolean atomic `0` (which is an incorrect value for the `1/:1` case).

### Use These Combinations

Combinations using `x /: y` that have exceptionally good performance include:

**What it does****Type;**

**Precisions;**

Ranks**Syntax****Variants;**

**Restrictions****Benefits;**

**Bug Warnings**Find `x`th-largest value of`y``x`is a Boolean or integer atom,`y`is an integer or floating-point list`x ({ /:~) y`**not**`\:`Partitions `y`using a randomly-selected pivot, so time and space results are variable, even for unchanging arguments