open String
open Str

let rec sort swapOccurred (result: int list) (list: int list) =
  match list with
  | [] ->
    if swapOccurred then sort false [] (List.rev result)
    else List.rev result
  | x :: y :: tail ->
    if x <= y then sort swapOccurred (x :: result) (y :: tail)
    else sort true (y :: result) (x :: tail)
  | x :: tail -> sort swapOccurred (x :: result) [];;

let rec string_of_list result list =
  match list with
  | [] -> result
  | x :: tail ->
    if String.length result == 0 then string_of_list (string_of_int x) tail
    else string_of_list (result ^ " " ^ string_of_int x) tail;;

read_line()
|> Str.split (Str.regexp " ")
|> List.map int_of_string
|> sort false []
|> string_of_list ""
|> print_endline

