I have data in following form, I wanted to sort the usernames column based on specfic user_id that I have to found from user_ids array.
usernames | empno | user_ids |
------------------+---------------------
{ Akon, Den } | 11 | { 12, 13 } |
{ John, Nash } | 7 | { 15, 12 } |
{ Ahmad, Umar }| 9 | { 18, 12 } |
Forexample, usernames with user_id = 12 should be shown first. Result would look like as below
usernames | empno |
------------------+--------
{ Akon, Den } | 11 |
{ Nash, John } | 7 |
{ Umar, Ahmad }| 9 |
I am sure there would be some easiest way of doing this in Postgres. This structure is just an example.