I have a table with a String column "grades" which includes the following ['uni', '9','10',11','12'].
I cannot change this column into an Int.
I have the following sort code:
Course.findAll({
order: [
['grade', 'ASC']
],
...
but sorting it by grade will give me the following order:
['10','11', '12', '9', 'uni' ]
Obviously I don't want it to be in this order. I looked into the Sequelize docs and they seem to have a way to submit a custom function for the ordering, but I don't have an example of how that would look like:
// Will order by otherfunction(`col1`, 12, 'lalala') DESC
[sequelize.fn('otherfunction', sequelize.col('col1'), 12, 'lalala'), 'DESC'],
(https://sequelize.org/master/manual/model-querying-basics.html#ordering-and-grouping)
Does anyone know of an implementation to do this?