How do I sort this custom list of sticky posts

This should do the trick:

$sticky = get_option( 'sticky_posts' );
$args = array(
    'posts_per_page' => -1,
    'post__in'  => $sticky,
    'ignore_sticky_posts' => 1
);

$query = new WP_Query( $args );
$ids_by_category = array();

while ($query->have_posts()) {
    $query->the_post();          
    $post_categories = wp_get_post_categories(get_the_ID()); 
    foreach($post_categories as $c){
        $cat = get_category($c);
        $ids_by_category[$cat->slug][] = get_the_ID();
    }
}

// sort by key
ksort($ids_by_category);

foreach ($ids_by_category as $category_slug => $ids) {
    foreach ($ids as $id) {
        printf(
            '<a href="https://wordpress.stackexchange.com/questions/235659/%s">%d</a> %s<br>',
            get_permalink($id),
            $id,
            $category_slug
        );
    }
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)