order by current user id in wordpress

following snippet to list down drafts and order by current user , so that current users draft post appear first and then other draft, you can use same for other posts post type as well.

$drafts = $wpdb->get_results(
"SELECT ID, post_title
FROM $wpdb->posts
WHERE post_status = 'draft'
ORDER BY CASE WHEN user_id = 'get_current_user_id()' THEN 1 ELSE 2 END"
);

in case you want to fetch published post of current user first then

$posts = $wpdb->get_results(
"SELECT ID, post_title
FROM $wpdb->posts
WHERE post_status = 'publish'
ORDER BY CASE WHEN user_id = 'get_current_user_id()' THEN 1 ELSE 2 END"
);

for custom post type

$posts = $wpdb->get_results(
"SELECT ID, post_title
FROM $wpdb->posts
WHERE post_status = 'publish'
AND post_type ="page"
ORDER BY CASE WHEN user_id = 'get_current_user_id()' THEN 1 ELSE 2 END"
);