Wordpress sort category dropdown list?


Staff member
I am using User-Submitted-Posts Plugin in order to let users submit their images to my wordpress site. Each image is uploaded within a category. The categories are set in the wordpress admin area and are pulled into the submission form using the following code.

My only problem is that this web form pulls the categories through ordered by their category ID not in alphabetical order. Therefore when i ADD a category even if it begins with the letter A, it will appear at the bottom.

Can anyone let me know how to edit the following code to make all categories list in ASC alphabetical order?

 <li class="usp_category">
                <label for="user-submitted-category" class="usp_label"><?php _e('Categories'); ?></label>
                    <select class="usp_select" name="user-submitted-category" id="user-submitted-category">

                        <?php foreach($settings['categories'] as $categoryId) { $category = get_category($categoryId); if(!$category) { continue; } ?>
                        <option class="usp_option" value="<?php echo $categoryId;?> "><?php $category = get_category($categoryId); echo htmlentities($category->name); ?></option>
                        <?php } ?>