List categories with posts

Finally I resolved the solution this way:

$hg_categories = get_categories();

            foreach($hg_categories as $hg_category) {
                echo '<h3>' . $hg_category -> name . '</h3>';
                $hg_posts = get_posts(array('numberposts' => -1, 'category' => $hg_category -> cat_ID));
                foreach ($hg_posts as $hg_post) {

                    if ($hg_post -> ID == get_the_ID()) {
                        echo '<li class = "current-post"><a href = "';
                        } else {
                        echo '<li><a href = "';
                    }                   
                        echo get_permalink ($hg_post -> ID);
                     echo '">';
                        echo $hg_post -> post_title;
                    echo '</a></li>';
                }
            }

if anyone have a better solution, please let me know, thank you.