array-rearrange

WebJar for array-rearrange

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

array-rearrange
Last Version

Last Version

2.2.2
Release Date

Release Date

Type

Type

jar
Description

Description

array-rearrange
WebJar for array-rearrange
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/dy/array-rearrange

Download array-rearrange

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/array-rearrange/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>array-rearrange</artifactId>
    <version>2.2.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/array-rearrange/
implementation 'org.webjars.npm:array-rearrange:2.2.2'
// https://jarcasting.com/artifacts/org.webjars.npm/array-rearrange/
implementation ("org.webjars.npm:array-rearrange:2.2.2")
'org.webjars.npm:array-rearrange:jar:2.2.2'
<dependency org="org.webjars.npm" name="array-rearrange" rev="2.2.2">
  <artifact name="array-rearrange" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='array-rearrange', version='2.2.2')
)
libraryDependencies += "org.webjars.npm" % "array-rearrange" % "2.2.2"
[org.webjars.npm/array-rearrange "2.2.2"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

array-rearrange experimental Build Status

Reorder elements within array by index.

npm install array-rearrange

const reorder = require('array-rearrange')

let arr = reorder([9,8,7,6], [3,2,1,0]) // [6,7,8,9]

let arr2 = reorder([3,3, 2,2, 1,1], [2,1,0]) // [1,1, 2,2, 3,3]

API

array = reorder(array, index, stride=1)

Shuffle elements in array according to the index array passed. Permutes original array. index array should contain unique indexes. Pass stride to indicate groups of elements to shuffle.

Originally based on the reference solution, which turns out to be wrong, so algorithm is fully rewritten.

See also

Versions

Version
2.2.2