Except as otherwise provided, a court may order a juvenile who is charged with the commission of a delinquent act or a criminal defendant who has not been convicted of a crime of violence to perform community service and assign the juvenile or defendant to a particular work project:
(1) instead of payment of any fines and court costs imposed; or
(2) as a condition of:
(i) probation, whether granted under § 6-220 or § 6-225 of the Criminal Procedure Article or otherwise;
(ii) a suspended sentence;
(iii) a case being placed on a stet docket; or
(iv) a juvenile being subject to a diversionary program.