Q:

Making 2 multidimensional arrays to align back in the right order after sorting

I have 2 multidimensional arrays. One is for the artist and the other is for the songs.
After entering the 4 artists and 3 songs each and after sorting each arrays, the songs stay in the same position but the artists get shuffled around. 
I am trying to make the songs follow the artist after they have both been sorted. Below is the output and the code. 
Let me know if you need to see more of my code and thanks in advance.
I am trying to post my code on stackoverflow but it keeps saying code is not properly formatted. This is my first time using stackoverflow
This is the code I have so far
    sortArtists(artists, Artistsnum); 
    sortSongs(songsArtist1, numOfSongs);
    sortSongs(songsArtist2, numOfSongs);
    sortSongs(songsArtist3, numOfSongs);
    sortSongs(songsArtist4,numOfSongs);
 /*
 * Use here the function shuffleSongs to shuffle all the songs
 * Print the list of shuffled songs
 */
    // print the songs

printSongs(songsArtist1, artists[0]);
printSongs(songsArtist2, artists[1]);
printSongs(songsArtist3, artists[2]);
printSongs(songsArtist4, artists[3]);

  return 0;
}
// Guard for entering number of artist brought in frompointerconstantwo.c    
//  loop through entire string
//  for(; *sPtr != '\0'; ++sPtr)    // no initialisation
//  {
//      printf("%c",*sPtr);
//  }

int insertSongs(char songs [3][80])
{
    int i, length;
    // Insert the songs
    for(i=0;i<3;i++)
    {
        printf("Insert Song %d: ", i+1);
        fgets(songs[i],80,stdin);

        // If the return command is pressed it
        if(songs[i][0]=='\n')
            break;

        // Remove the carriage return from the song
        length = strlen(songs[i]);
        songs[i][length - 1] = '\0';
    }

    if(i>0)
        return i;
    else
        return 0; 
}
    char newartist[4][80];

void printSongs(char songs[3][80], char artists[4][80])// added new  
{

    int i;
    for(i=0; i<4;i++)
    {
        printf("List of Artist %s",artists[i]);

        for(i=0;i<3; i++)
        {
            printf("\nSong %d: %s\n", i+1, songs[i]);
        }

    }
}

void sortArtists(char sortedArtists[][80] , int numOfArtist){

//    int numOfArtist = 4;
    size_t i = 0;
    size_t j = 0;
    size_t minIndex = 0;
    size_t minIndexChanged = 0;
    char artists[80];   // i added this myself not in note

    char swap [MAX_LENGTH];
    char newartist[4][80];

    printf("\nThe number of Artist is %d\n", numOfArtist);

     for(i=0; i < 3 ; i++){        // count_name = 4-1
     for(j=i+1; j< 4; j++)
    {
        if(strcmp(sortedArtists[i],sortedArtists[j]) > 0)
        {
            strcpy(swap,sortedArtists[i]);
            strcpy(sortedArtists[i],sortedArtists[j]);
            strcpy(sortedArtists[j],swap);
        }
    }
 }

}

/*
* This method sorts the songs of a specific artist alphabetically. It takes 
as input:
* - songsOfAnArtist: the array of the songs of an artist that was provided 
from the standard input
* - numOfArtists: the number of artists provided from the standard input
*/
void sortSongs(char songs[][80], int numOfSongs){
    size_t i = 0;
    size_t j = 0;
    size_t minIndex = 0;
    size_t minIndexChanged = 0;

    printf("Here\n");
   // char songs[80];   // i added this myself not in note

    char swap [80];

    printf("\nThe number of songs is %d\n", numOfSongs);

    for(i=0; i < 2 ; i++){
        for(j=i+1; j< 3; j++)
        {
            if(strcmp(songs[i],songs[j]) > 0)
            {
               printf(songs[i]);  // new
               strcpy(swap,songs[i]);
               printf(songs[i]); // new
               strcpy(songs[i],songs[j]);
               strcpy(songs[j],swap);
            }
        }
    }

    for (i = 0; i < 3; i++){
        printf("%s\n", songs[i]);
    }

}

A:

An identifier could be prepended to each line to identify the associated artist and song. Sort on the values following the identifier and print songs if the identifier for the artist matches the identifier for the song.
#include <stdio.h>
#include <string.h>

#define ARTISTS 4
#define SONGS 3
#define ID 3
#define LENGTH 80

int main ( void) {
    char artists[ARTISTS][LENGTH] = { { ""}};
    char songs[SONGS * ARTISTS][LENGTH] = { { ""}};
    char input[LENGTH - ID] = "";//shorter to allow for leading ID when concatenated
    int id = 0;

    for ( int each = 0; each < ARTISTS; each++) {
        id++;
        printf ( "enter artist name %d of %d\n", each + 1, ARTISTS);
        fgets ( input, LENGTH - ID, stdin);
        input[strcspn ( input, "\n")] = '\0';//remove trailing newline
        if ( '\0' == input[0]) {
            break;
        }
        sprintf ( artists[each], "%*d%s", ID, id, input);//print the id and name to artists[]
        for ( int loop = 0; loop < SONGS; loop++) {
            printf ( "\tfor %s, enter song title %d of %d\n", &artists[each][ID], loop + 1, SONGS);
            fgets ( input, LENGTH - ID, stdin);
            input[strcspn ( input, "\n")] = '\0';//remove trailing newline
            if ( '\0' == input[0]) {
                break;
            }
            sprintf ( songs[loop + each * SONGS], "%*d%s", ID, id, input);//print the id and name to songs[]
        }
    }
    //sort artists
    for ( int each = 1; each < ARTISTS; each++) {
        int loop = each;
        while ( loop) {
            if ( 0 > strcmp ( &artists[loop][ID], &artists[loop - 1][ID])) {
                char swap[LENGTH] = "";
                strcpy ( swap, artists[loop]);
                strcpy ( artists[loop], artists[loop - 1]);
                strcpy ( artists[loop - 1], swap);
            }
            else {
                break;
            }
            loop--;
        }
    }

    //sort songs
    for ( int each = 1; each < ARTISTS * SONGS; each++) {
        int loop = each;
        while ( loop) {
            if ( 0 > strcmp ( &songs[loop][ID], &songs[loop - 1][ID])) {
                char swap[LENGTH] = "";
                strcpy ( swap, songs[loop]);
                strcpy ( songs[loop], songs[loop - 1]);
                strcpy ( songs[loop - 1], swap);
            }
            else {
                break;
            }
            loop--;
        }
    }

    //print artists and songs
    for ( int each = 0; each < ARTISTS; each++) {
        if ( artists[each][0]) {
            printf ( "artist %s\n", &artists[each][ID]);//print name after id
            for ( int loop = 0; loop < ARTISTS * SONGS; loop++) {
                if ( 0 == strncmp ( artists[each], songs[loop], ID)) {//match the id
                    printf ( "\tsong %s\n", &songs[loop][ID]);//print the song after the id
                }
            }
        }
    }

    return 0;
}

