Preheat your oven to 350°F (175°C).
In a large mixing bowl, combine the drained crushed pineapple and sugar.
Mix in the grated cheddar cheese until well combined.
In a separate bowl, combine the crushed Ritz crackers and melted butter.
Stir half of the cracker mixture into the pineapple mixture.
Pour the pineapple mixture into a greased baking dish.
Spread the remaining cracker mixture evenly on top.
If using, sprinkle shredded coconut over the top.
Bake in the preheated oven for 30 minutes or until golden brown.
Let it cool for a few minutes before serving.