Skip to the content

Jarajaraジャラジャラ

Draw mahjong tiles, arrange racks and stacked boards, and play seeded Awase alone or at a shared table.

Jarajara is the Japanese sound of mahjong tiles rattling together. About the name

Contents

Reference · Tiles, layouts and deals

sortSlotsfunction

The slots of a layout, as their numbers, put in order by the keys: ["z", "y", "x"] is layer by layer, row by row, across (the layout's own order), ["x"] lines them up from the left, ["-z"] has the top of the stacks first. Slots equal in every key keep their own order, and a key left out is settled last, in the order x, y, z, so the result is the same whatever the keys.

Import it

import { sortSlots } from "@johnmorrisdotca/jarajara";

Definition

function sortSlots(layout: MahjongLayout, keys?: readonly SlotSortKey[]): number[]

Parameters

NameTypeDescription
layoutMahjongLayout

The native stacked tile positions.

keys (optional)readonly SlotSortKey[]

The native slot axes and sort directions.

Returns

number[]

The slots of a layout, as their numbers, put in order by the keys: ["z", "y", "x"] is layer by layer, row by row, across (the layout's own order), ["x"] lines them up from the left, ["-z"] has the top of the stacks first. Slots equal in every key keep their own order, and a key left out is settled last, in the order x, y, z, so the result is the same whatever the keys.

Examples

import { layoutFor, sortSlots } from "@johnmorrisdotca/jarajara";

const layout = layoutFor(4)!;
console.log(sortSlots(layout,["z","y","x"]));
[
  0, 1, 2, 3,
  4, 5, 6, 7
]

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/jarajara 1.7.0.