Skip to main content
added 62 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

C (gcc), 132 128128 126 bytes

char*k;g(a,b,i,r)char**a,**b;{r=k[i%strlen(k)];(r^(i[*a]?:-1))-(r^(i[*b]?:-2))?:g(a,b,i+1);}f(c,v)char**v;int*v;{k=*v;qsort(v,c,8,g);} 

Takes an argument count and a pointer to a string array (the key, followed by the strings to be sorted) and modifies the string array in-place.

The code is highly non-portable and requires 64-bit pointers, gcc, and glibc.

Try it online!Thanks to @ceilingcat for golfing off 2 bytes!

Try it online!

C (gcc), 132 128 bytes

char*k;g(a,b,i,r)char**a,**b;{r=k[i%strlen(k)];(r^(i[*a]?:-1))-(r^(i[*b]?:-2))?:g(a,b,i+1);}f(c,v)char**v;{k=*v;qsort(v,c,8,g);} 

Takes an argument count and a pointer to a string array (the key, followed by the strings to be sorted) and modifies the string array in-place.

The code is highly non-portable and requires 64-bit pointers, gcc, and glibc.

Try it online!

C (gcc), 132 128 126 bytes

char*k;g(a,b,i,r)char**a,**b;{r=k[i%strlen(k)];(r^(i[*a]?:-1))-(r^(i[*b]?:-2))?:g(a,b,i+1);}f(c,v)int*v;{k=*v;qsort(v,c,8,g);} 

Takes an argument count and a pointer to a string array (the key, followed by the strings to be sorted) and modifies the string array in-place.

The code is highly non-portable and requires 64-bit pointers, gcc, and glibc.

Thanks to @ceilingcat for golfing off 2 bytes!

Try it online!

added 120 characters in body
Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

C (gcc), 132132 128 bytes

char*K;gchar*k;g(a,b,i,r)char**a,**b;{r=K[i%strlenr=k[i%strlen(Kk)];(r^(i[*a]?:-1))-(r^(i[*b]?:-2))?:g(a,b,i+1);}f(k,nc,xv)char*k,**x;char**v;{K=k;qsortk=*v;qsort(xv,nc,8,g);} 

This shouldTakes an argument count and a pointer to a string array (the key, followed by the strings to be sorted) and modifies the string array in-place.

The code is highly non-portable (requiresand requires 64-bit pointers, gcc, and glibc).

Try it online!Try it online!

C (gcc), 132 bytes

char*K;g(a,b,i,r)char**a,**b;{r=K[i%strlen(K)];(r^(i[*a]?:-1))-(r^(i[*b]?:-2))?:g(a,b,i+1);}f(k,n,x)char*k,**x;{K=k;qsort(x,n,8,g);} 

This should be highly non-portable (requires 64-bit pointers, gcc, and glibc).

Try it online!

C (gcc), 132 128 bytes

char*k;g(a,b,i,r)char**a,**b;{r=k[i%strlen(k)];(r^(i[*a]?:-1))-(r^(i[*b]?:-2))?:g(a,b,i+1);}f(c,v)char**v;{k=*v;qsort(v,c,8,g);} 

Takes an argument count and a pointer to a string array (the key, followed by the strings to be sorted) and modifies the string array in-place.

The code is highly non-portable and requires 64-bit pointers, gcc, and glibc.

Try it online!

Source Link
Dennis
  • 211.7k
  • 41
  • 380
  • 830

C (gcc), 132 bytes

char*K;g(a,b,i,r)char**a,**b;{r=K[i%strlen(K)];(r^(i[*a]?:-1))-(r^(i[*b]?:-2))?:g(a,b,i+1);}f(k,n,x)char*k,**x;{K=k;qsort(x,n,8,g);} 

This should be highly non-portable (requires 64-bit pointers, gcc, and glibc).

Try it online!