What happens if a foreigner is sentenced to a freedom-restricting penalty in a misdemeanour? Can the court order their deportation? 
Yes, if a foreigner is sentenced to a freedom-restricting penalty in a misdemeanour, the court has the authority to order their deportation from the state or opt for deportation instead of the freedom-restricting penalty, unless there are specific laws stating otherwise.