How to write a algorithm to randomize the posts array.

Description-

  1. You have an array of id’s of posts you have to
    print on a user’s screen.

  2. User could see the post of last 3 days and these
    3 day’s posts should be randomised.

  3. Then you have to print posts posted between 3-10
    day’s and also these are randomised.

  4. Then 10-30 days posts and then all remaining posts.

  5. No repetition of posts on user screen.