A weighted version of a rearrangement inequality