Don't know the mysql syntax but in vfp I'd do this:
select codename, iif(empty(codename),'B','A') as sortorder, *
from projects
order by sortorder, codename
the projects with a codename are given 'A' so they automatically go to the top.
By the same logic you could also have
iif(empty(codename),projectname, codename) as sortorder and then it would just use the project name if codename wasn't given.
REMEMBER TO CHECK MY SYNTAX!