PricingBlog

Shuffle Array

  • julienboid-1173923917979721788

    Julien

    2 years ago

    Hello everyone, Is there a possibility to shuffle the order of an Array ? Thanks
  • erikbeus-1173925439891308555

    Erik Beuschau

    2 years ago

    It's not part of our core library atm no. It should be possible to create a custom formula for this, but I might add it to our core library anyway. Let me get back to you
  • jacobkofoed-1173925734012694549

    Jacob Kofoed

    2 years ago

    If you want to randomly shuffle it, you can achieve it with the Sort and a number that is 1/2 positive/negative.
    1173925733681352704-CleanShot_2023-11-14_at_10.00.202x.png
    🤯1
    💡1
    😅1
  • erikbeus-1173927941936250930

    Erik Beuschau

    2 years ago

    That has its drawbacks though in terms of correctness 😅 https://javascript.info/array-methods#shuffle-an-array
    🤦1
  • erikbeus-1173931336055140352

    Erik Beuschau

    2 years ago

    @Julien there should be a new formula available in a bit that lets you shuffle an array or a string 🙂
    ❤️1
  • julienboid-1173933815769600041

    Julien

    2 years ago

    Thank's guys ! Jacob, I don't understand anything about your formula logic but if it works I'll take it 😅 👌
  • jacobkofoed-1173934069915074601

    Jacob Kofoed

    2 years ago

    Don't use mine. As @Erik Beuschau pointed out, it is flawed. Wait a few minutes and check the formula for Erik's Shuffle formula to get a "truly" random shuffle.
    💯1
  • julienboid-1173944035308740659

    Julien

    2 years ago

    Ok, thank you !!!