/**
 * Una canción: título, artista y duración en segundos.
 * El orden natural es por título; si empatan, por artista y luego por duración.
 * Así compareTo da 0 solo cuando equals da true (es consistente con equals).
 */
public record Song(String title, String artist, int seconds) implements Comparable<Song> {

    @Override
    public int compareTo(Song other) {
        int byTitle = title.compareTo(other.title);
        if (byTitle != 0) {
            return byTitle;
        }
        int byArtist = artist.compareTo(other.artist);
        if (byArtist != 0) {
            return byArtist;
        }
        return Integer.compare(seconds, other.seconds);
    }
}
