Following function will create wordpress post’s selectbox / dropdown sorted by category.

Add the following code in your theme’s function.php file

function display_post_selectbox($class_name='') {
global $wpdb, $post;
$table_prefix = $wpdb->prefix;
$the_output = NULL;
$last_posts = (array)$wpdb->get_results("
SELECT {$table_prefix}terms.name, {$table_prefix}terms.term_id
FROM {$table_prefix}terms, {$table_prefix}term_taxonomy
WHERE {$table_prefix}terms.term_id = {$table_prefix}term_taxonomy.term_id
AND {$table_prefix}term_taxonomy.taxonomy = 'category'
{$hide_check} 
");
if (empty($last_posts)) {
return NULL;
}
$used_cats = array();;
$i = 0;
foreach ($last_posts as $posts) {
if (in_array($posts->name, $used_cats)) {
unset($last_posts[$i]);
} else {
$used_cats[] = $posts->name;
}
$i++;
}
$last_posts = array_values($last_posts);
$the_output .= '<select name="wordpress_posts" class="'.$class_name.'">';
foreach ($last_posts as $posts) {
$the_output .= '<optgroup label="'.apply_filters('list_cats', $posts->name, $posts).'">';
$where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'" , $r );
$arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND ID IN (Select object_id FROM {$table_prefix}term_relationships, {$table_prefix}terms WHERE {$table_prefix}term_relationships.term_taxonomy_id =" . $posts->term_id . ") ORDER BY post_date DESC");
foreach ( $arcresults as $arcresult ) {
$the_output .= '<option label="'.apply_filters('the_title', $arcresult->post_title).'" value="'.apply_filters('the_title', $arcresult->post_title).'">'.apply_filters('the_title', $arcresult->post_title) . '</option>';
}
$the_output .= '</optgroup>';
}
$the_output .= '</select>';
return $the_output;
}

To display the selectbox add following code in your theme’s php file where you want to display it.

<?php
if(function_exists('display_post_selectbox'))
{
echo display_post_selectbox();
}
?>