The Australian sharemarket closed higher on Tuesday, as rising oil and commodity prices fuelled a rally in mining and energy stocks.