Mathematica 124 bytes
x = StringLength@(y = "");
For[i = 1, ! (s = y~StringTake~i)~StringRepeat~x~StringContainsQ~y,i++];
First@Sort@StringPartition[s <> s, i, 1]
Whitespace and newlines (in the presence of semicolons at the ends of lines) have no meaning in Mathematica and are included here for readability.
Input goes in between the quotation marks in the first line. If recast as a function, that takes string input like so:
f=(x=StringLength@(y=#);For[i=1,!(s=y~StringTake~i)~StringRepeat~x~StringContainsQ~y,i++];First@Sort@StringPartition[s<>s,i,1])&
f@"bca"
(* "abc" *)
f@"abaa"
(* "aab" *)
then it's 128 bytes.
The For loop takes the first i characters of the input and repeats them at least up to the length of the input, then checks if the input is a substring of the result. Having found the length of the period of the string, the StringPartition command concatenates two copies of that period and takes all substrings of that length from it (basically gets all cyclic permutations), then First@Sort finds the first one of them when lexicographically ordered.
Output should be in any order? Say output can be
bacin your example rather thanabc? – Ant's – 2011-06-15T17:10:44.313@GroovyUser: no, the input is not a substring of a repeated pattern of
bacs. – Keith Randall – 2011-06-15T17:28:18.750But the input could consist of a substring of
(bca)^n, which meansbcais just as valid for the given example asabc. – JAB – 2011-06-16T18:12:50.7201@JAB:
bcais not the smallest lexicographically. – Keith Randall – 2011-06-16T20:47:02.673Ah, I somehow missed that part. – JAB – 2011-06-17T13:40:27.443