If you've been told to update a list of records with the new values in the DB, and it's hard to do it manually, you can run a script within Tinker.
The structure might look something like this:
| const arr = [1, 2, 4, 5, 5, 5, 2, 4, 3, 4, 3, 3, 2, 3, 2, 1, 1, 2, 1] | |
| Array.prototype.sortByFrequency = function () { | |
| let frequency = {} | |
| let sorting = [] | |
| let new_arr = [] | |
| this.forEach(value => frequency[value] = (frequency[value] || 0) + 1) | |
| for (let key in frequency)sorting = [...sorting, [key, frequency[key]]] |