\documentclass{article}
\usepackage{xsim}
\usepackage{lipsum}

\DeclareExerciseCollection[difficulty=easy]{easy}
\DeclareExerciseCollection[difficulty=medium]{medium}
\DeclareExerciseTagging{difficulty}

\xsimsetup{collect}

\begin{document}

\begin{exercise}[use,print]
  outside before
\end{exercise}

\begin{exercise}[difficulty=easy,points=1]
  foo one \lipsum[4]
\end{exercise}
\begin{solution}
  foo one \lipsum[4]
\end{solution}
\begin{exercise}[difficulty=medium,points=1]
  foo two \lipsum[4]
\end{exercise}
\begin{solution}
  foo two \lipsum[4]
\end{solution}
\begin{exercise}[difficulty=easy,points=1]
  foo three \lipsum[4]
\end{exercise}
\begin{solution}
  foo three \lipsum[4]
\end{solution}

\section{Easy}
\printcollection{easy}

\section{Medium}
\printcollection{medium}

\printsolutions[difficulty=medium]

\end{document}
