Skip to content

Instantly share code, notes, and snippets.

@mikedfunk
Created June 17, 2022 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikedfunk/6e2efb74695e5c6c90ad084d6d2cbaf6 to your computer and use it in GitHub Desktop.
Save mikedfunk/6e2efb74695e5c6c90ad084d6d2cbaf6 to your computer and use it in GitHub Desktop.

Examples with ascending order


E.g. Move D to B (no room for any)

Start:

id order
A 1
B 2
C 3
D 4
E 45

End:

id order
A 1
D 2
B 3
C 4
E 45

Request:

{
  "D": 2,
  "B": 3,
  "C": 4
}

E.g. Move D to B (room available)

Start:

id order
A 1
B 20
C 30
D 40
E 45

End:

id order
A 1
D 10
B 20
C 30
E 45

Request:

{
  "D": 10
}

E.g. Move E to A (some room available)

Start:

id order
A 1
B 2
C 20
D 40
E 45

End:

id order
E 1
A 2
B 10
C 20
D 40

Request: (note I didn't have to send C or D)

{
  "E": 1,
  "A": 2,
  "B": 10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment