Just now digging into the archives of Google and not found a normal solution of this problem. All the proposed options have only worked in one of the variations - or only with the sortable pluging, or only with the cookie plugin.
So, let's begin.
We need the following libraries and plugins.
jQuery 1.6.4 version or later. If you want to adapt the code under an older version, simply replace the prop() for attr()
jQuery UI 1.12+ and above with modules Core, Widget, Mouse, Sortable, Tabs