If what you’re asking of these students can easily be automated by a tool then the problem is in the assignment. Either don’t request it, knowing it can be automated with ease, or accept that bubble sorts are a long solved problem and move on to teaching other things.
Lest anyone think I’m saying don’t teach important concepts or that such things no longer matter: there’s a whole world of principles and fundamentals that can be taught and assessed without fizzbuzzing 100 students who already had access to Google and StackOverflow before Copilot came along.
Yes, directly assessing hands-on coding would be much better, but these tiny snippets aren’t really indicative of real-world tasks that will be needed anyway (given that almost anything so foundational will almost certainly be in a standard library), it doesn’t really prepare students for real-world development work, and there’s a general expectation that new graduates are going to be very very green and therefore need a lot of handholding regardless. Even more than that, you’ve no way of detecting plagiarism already in these assignments given that a couple of basic rename refactors is going to stop you from proving the code was lifted from elsewhere to begin with.