mirror of
https://github.com/acid-info/logos-ordinals-dashboard.git
synced 2025-02-05 01:53:49 +00:00
feat: shuffle operators
This commit is contained in:
parent
894d30c55f
commit
e116d09fc0
@ -12,7 +12,7 @@ import {
|
||||
SKIN,
|
||||
} from '../../../constants/operators'
|
||||
import { Archetype } from '../../../types/operators'
|
||||
import { processOperators } from '../../../utils/operators'
|
||||
import { processOperators, shuffleOperators } from '../../../utils/operators'
|
||||
|
||||
interface ExploreSectionProps {}
|
||||
|
||||
@ -53,7 +53,7 @@ const ExploreSection: React.FC<ExploreSectionProps> = () => {
|
||||
)
|
||||
})
|
||||
|
||||
const randomizedOperators = selectedOperators?.sort(() => Math.random() - 0.5)
|
||||
const randomizedOperators = shuffleOperators(selectedOperators)
|
||||
|
||||
const handleFilterChange = (
|
||||
selectedOptions: string[],
|
||||
|
@ -68,3 +68,13 @@ export function findOperatorById(
|
||||
(operator) => String(operator.id) === String(operatorId),
|
||||
)
|
||||
}
|
||||
|
||||
export function shuffleOperators(
|
||||
array: ProcessedOperator[],
|
||||
): ProcessedOperator[] {
|
||||
for (let i = array?.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1))
|
||||
;[array[i], array[j]] = [array[j], array[i]]
|
||||
}
|
||||
return array
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user