[Question]
  [
Given an input of a list of slices of a string, output the original string.
Each slice will be given as a list of length 2, containing the start position
of the slice (an integer ≥0) and the slice itself. If your language does not
support arrays of arbitrary types, you may also take this as a struct or
similar, or simply a string consisting of the number, a space, and then the
slice.
The order of the two elements of each slice is up to you. Furthermore, if you
choose to use the representation of slices as a length-2 array, you may take
input as either a 2-dimensional array or a single flat array. Finally, the
integer representing position may be either zero-indexed or one-indexed (all
the examples here are zero-indexed).
The input will always be sufficient to determine the entire string up to the
highest position given. That is, there will be no "holes" or "gaps." Therefore,
the output must not contain any extra trailing or leading characters (other
than the typical optional trailing newline). The input will always be
consistent, and no slices will conflict with each other.
Since this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), the shortest code in bytes will win.
Test cases:
```
In                                                Out
-----------------------------------------------------------
[[2, "CG"], [0, "PP"], [1, "PC"]]               | PPCG
[[0, "foobarbaz"]]                              | foobarbaz
[[0, "foobar"], [6, "baz"]]                     | foobarbaz
[[2, "ob"], [5, "rba"], [0, "fooba"], [8, "z"]] | foobarbaz
[[0, "fo"], [0, "fooba"], [0, "foobarbaz"]]     | foobarbaz
```
  
[Answer]
## Python 2, 49 bytes
```
lambda l:`map(max,*[' '*n+s for n,s in l])`[2::5]
```
First, lines up the strings by padding their offsets with spaces (shown as underscores for clarity)
```
[[2, "CG"], [0, "PP"], [1, "PC"]] 
__CG
PP
_PC
```
Then, uses `map` to `zip` and take the maximum of each column, which ignores the smaller values of spaces (the smallest printable character) and `None`s where some strings were too short.
```
__CG
PP
_PC
PPCG
```
Finally, `''.join` to a string using the `[2::5]` trick.
[Answer]
## Haskell, 57 bytes
```
import Data.List
map snd.sort.nub.(>>= \(n,s)->zip[n..]s)
```
Usage example:
```
*Main> map snd.sort.nub.(>>= \(n,s)->zip[n..]s) $ [(2,"CG"),(0,"PP"),(1,"PC")]
"PPCG"
```
How it works: make pairs of `(index,letter)` for every letter of every slice, concatenate into a single list, remove duplicates, sort by index, remove indices. 
[Answer]
# Perl, 25
Added +2 for `-lp`
Get the input from STDIN, e.g.
```
perl -lp slices.pl
2 CG
0 PP
1 PC
```
(Close with ^D or ^Z or whatever closes STDIN on your system)
`slices.pl`:
```
/ /;$r|=v0 x$`.$'}{*_=r
```
[Answer]
## JavaScript (ES6), 61 bytes
```
a=>a.map(([o,s])=>[...s].map(c=>r[o++]=c),r=[])&&r.join``
```
Edit: Saved 4 bytes thanks to @edc65.
[Answer]
# Jelly, ~~10~~ 9 bytes
```
Ḣ0ẋ;Fµ€o/
```
[Try it online!](http://jelly.tryitonline.net/#code=4biiMOG6iztGwrXigqxvLw&input=&args=W1syLCAib2IiXSwgWzUsICJyYmEiXSwgWzAsICJmb29iYSJdLCBbOCwgInoiXV0)
### How it works
```
Ḣ0ẋ;Fµ€o/  Main link. Input: A (list of pairs)
     µ€    Convert the chain to the left into a link, and apply it to each pair.
Ḣ          Pop the first element.
 0ẋ        Yield a list of that many zeroes.
   ;F      Concatenate the list of zeroes with the popped, flattened pair.
       o/  Reduce the generated lists by logical OR.
           Since all characters are truthy, this overwrites zeroes with characters,
           but never characters with zeroes.
```
[Answer]
# [Factor](https://factorcode.org), 64 40 bytes
```
[ sbuf new tuck '[ _ copy ] assoc-each ]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=ZZA9CsIwHMXp6ikeWXQRVFCKjh3ERQRxKkXSkGBRm5q0iEpP4tJFD-Bt9DSmjVSqyZAH7_f-H7neBWWpVMXLcVbL2Xw6hlAnbLmK-Q6aHzIeM65BtZZMI5LQYSY0Jq1LC-ZczCXelGCAvJSLBUHvIz2CvpH5FxRShlSF9GyhP6fOVsioiciw7mJKEAytrpJ10MTc38q12UT_hslvWSq67rPjV0si5kekGdui7WMNJpMTAvsRXU7ZBoHlH3uawEeiojg1QGlZoyjs-wY)
This answer makes use of the fact you can set arbitrary indices of a growable sequence (in this case a string buffer) and the sequence will expand appropriately with default values. `copy` copies one sequence to another starting at an index; a perfect fit for this problem.
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), 15 bytes
```
''i"@Y:Y:tn:b+(
```
Works with [current version (13.0.0)](https://github.com/lmendo/MATL/releases/tag/13.0.0) of the language/compiler.
Input is with curly braces and single quotes. (Curly braces in MATLAB/MATL define *cell arrays*, which are lists that can have contents of arbitrary, possibly different types.) The test cases are thus:
```
{{2, 'CG'}, {0, 'PP'} {1, 'PC'}}
{{0, 'foobarbaz'}}
{{0, 'foobar'}, {6, 'baz'}}
{{2, 'ob'}, {5, 'rba'}, {0, 'fooba'}, {8, 'z'}}
{{0, 'fo'}, {0, 'fooba'}, {0, 'foobarbaz'}}
```
[**Try it online!**](http://matl.tryitonline.net/#code=JydpIkBZOlk6dG46Yiso&input=e3syLCAnb2InfSwgezUsICdyYmEnfSwgezAsICdmb29iYSd9LCB7OCwgJ3onfX0)
```
''      % push empty string. This will be filled with the slices to produce the result
i       % take input: cell array of cell arrays. For example: {{0, 'foobar'}, {6, 'baz'}}
"       % for each (1st-level) cell
  @     %   push that cell. Example: {{0, 'foobar'}}
  Y:    %   unpack (1st-level) cell, i.e. push its contents. Example: {0, 'foobar'}
  Y:    %   unpack (2nd-level) cell array: gives number and substring. Example: 0, 'foobar'
  tn:   %   duplicate substring and generate vector [1,2,...,n], where n is length of
        %   current substring (in the example: 6)
  b+    %   add input number that tells the position of that substring within the whole
        %   string (in the example: 0; so this gives [1,2,...,6] again)
  (     %   assign substring to the total string, overwriting if necessary. Note that
        %   MATL uses 1-indexing
        % end for each
        % implicit display
```
[Answer]
# [J](http://jsoftware.com/), 24 bytes
```
[:u:3>./@u:-@(+#&>){.&>]
```
[Try it online!](https://tio.run/##VY3BCoJAEIbvPsVosKukqyZJDrVIQl0ipKsJq5FEl4XAi0avbqtmIMNcvu//Z55dpKOfhzpGlGoGoxXsECjY4AGqdRgkl9Ohy7DGgDM3rtGJzeWCcKtlhOedpZ33DLw2wyt@DJ@w9zww6Aw5I8wMSI2WO9fa/faQsFKvfKggOYo0FWkyUtP2LAW3tJKyLF5l0dBReBAqPlKh8HRkrcxGGVkKlRZDQDRTp5@@9eP/o90X "J – Try It Online")
## alternative, 24 bytes
```
[:u:[:>./(#&0@[,3 u:])&>
```
[Try it online!](https://tio.run/##bY7BCoJAEIbvPsVksOuSrmuS1FAiCXWJkK4mrEYSXYTAi0avbmNWEMQwl@/752eu3WKEXhaMcMG5YUpewgqBgw0KkNaREB92my7FGlMMpWuNmYpS24caM8HCThj7tYRe@2SjGp3ImoxZKFrJwuwlVZviER@mx@T9j@5rmbR8VqNwf7VxPl0qmNIfHpQQb3WS6CQeqGUrQXDJy6oq8luRN3wQCgLiA9WEPyUzMnMyVaEprV8B3Xxu@umv3vxb2j0B "J – Try It Online")
[Answer]
# [DUP](https://esolangs.org/wiki/DUP), 14 bytes
```
[0[$;$][,1+]#]
```
`[Try it here.](http://www.quirkster.com/iano/js/dup.html)`
Anonymous lambda. Usage:
```
2"CG"0"PP"1"PC"[0[$;$][,1+]#]!
```
NOTE: DUP does not really have arrays, so I hope this input format is okay.
# Explanation
Well, DUP's string comprehension is... interesting. Strings are stored as a series of number variables, each of which holds a charcode from the string. Something like `2"CG"` works as pushing 2 to the stack, then creating a string with index starting from 2.
Because these indexes are really variables, they can be overwritten. That's what the input is really doing: overriding! Try pressing `Step` on the interpreter site to get a better idea for this. After this, we get an unsliced string.
This is where the outputting comes in.
```
[            ] {lambda}
 0             {push 0 to the stack as accumulator}
  [   ][   ]#  {while loop}
   $;$         {duplicate, get var at TOS value, see if that var is defined}
        ,1+    {if so, output charcode at TOS and increment accumulator}
```
[Answer]
# PHP, 146 chars
Note: Evaling user input is *always* a good idea.
## Golfed
```
<?$a=[];$f=0;eval("\$b={$argv[1]};");foreach($b as$d){$f=$d[0];$e=str_split($d[1]);foreach($e as$c){$a[$f++]=$c;}}ksort($a);echo join('',$a)."\n";
```
## Ungolfed
```
<?php
$array = array();
$p = 0;
eval("\$input = {$argv[1]};");
foreach($input as $item)
{
    $p = $item[0];
    $str = str_split($item[1]);
    foreach($str as $part)
    {
        $array[$p++] = $part;
    }
}
ksort($array);
echo join('', $array)."\n";
?>
```
You can see that I'm just writing the input into an array with the specific key each char has and then output it all.
## Tests
`php unslice.php '[[0, "foobar"], [6, "baz"]]'` -> foobarbaz
`php unslice.php '[[2, "CG"], [0, "PP"], [1, "PC"]]'` -> PPCG
`php shorten.php unslice.php` -> Shortened script by 107 chars. :D
[Answer]
# [Ruby](https://www.ruby-lang.org/), 40 bytes
```
->a{s=""
a.sort.map{s[_1,_2.size]=_2}
s}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsEiN9ulpSVpuhY3NXTtEquLbZWUuBL1ivOLSvRyEwuqi6PjDXXijfSKM6tSY23jjWq5imuh6q8UlJYUK7hFR0cb6SgoObsrxeooRBsAmQEBYKYhiOmsFBsbywVXCZJOy89PSixKSqzCJQXWbQbkYqgBWZSfBJY3BTKBhsAtBWsF8yyAPKxmY1GL4R6I3xYsgNAA)
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `s`, 6 bytes
```
∩÷-∩vG
```
[Try it online! (test suite)](https://vyxal.pythonanywhere.com/#WyJzQSIsIiIsIuKIqcO3LeKIqXZHIiwiIiwiW1syLCBcIkNHXCJdLCBbMCwgXCJQUFwiXSwgWzEsIFwiUENcIl1dXG5bWzAsIFwiZm9vYmFyYmF6XCJdXVxuW1swLCBcImZvb2JhclwiXSwgWzYsIFwiYmF6XCJdXVxuW1syLCBcIm9iXCJdLCBbNSwgXCJyYmFcIl0sIFswLCBcImZvb2JhXCJdLCBbOCwgXCJ6XCJdXVxuW1swLCBcImZvXCJdLCBbMCwgXCJmb29iYVwiXSwgWzAsIFwiZm9vYmFyYmF6XCJdXSJd) Input as a list of `[num, str]`.
**Explanation:**
```
∩÷-∩vG # whole program
∩      # transpose (num and str in their own groups)
 ÷     # split into each item
  -    # prepend '-' to str num amount of times (vectorises)
   ∩   # transpose
    v  # for each item (i.e. vectorise next element)
     G # get max char
       # s flag: concatenate list into a string, then print
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-mh`](https://codegolf.meta.stackexchange.com/a/14339/), ~~15~~ 12 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
P=úUÎÄ hUÎUÌ
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LW1o&code=UD36Vc7EIGhVzlXM&input=W1syLCAib2IiXSwgWzUsICJyYmEiXSwgWzAsICJmb29iYSJdLCBbOCwgInoiXV0KLVE)
```
P=úUÎÄ hUÎUÌ     :Implicit map of each array U in input array W
P=               :Assign to P (an empty string, initially)
  ú              :Right pad P with spaces to length
   UÎ            :  First element of U
     Ä           :  Add 1
       h         :Replace the characters starting at index
        UÎ       :  First element of U
          UÌ     :  With last element of U
                 :Implicit output of last element of resulting array
```
[Answer]
## Seriously, 48 bytes
```
,`i@;l(;)+(x@#@k`M;`i@X@M`MMu' *╗`iZi`M`i╜T╗`MX╜
```
Seriously is *seriously* bad at string manipulation.
[Try it online!](http://seriously.tryitonline.net/#code=LGBpQDtsKDspKyh4QCNAa2BNO2BpQFhATWBNTXUnICrilZdgaVppYE1gaeKVnFTilZdgTVjilZw&input=W1syLCAib2IiXSwgWzUsICJyYmEiXSwgWzAsICJmb29iYSJdLCBbOCwgInoiXV0)
Explanation:
```
,`i@;l(;)+(x@#@k`M;`i@X@M`MMu' *╗`iZi`M`i╜T╗`MX╜
,                                                 get input
 `              `M;                               perform the first map and dupe
                   `     `MM                      perform the second map, get max element
                            u' *╗                 increment, make string of that many spaces, save in reg 0
                                 `   `M           third map
                                       `    `M    fourth map
                                              X╜  discard and push register 0
```
Map 1:
```
i@;l(;)+(x@#@k
i@;l            flatten, swap, dupe string, get length
    (;)+(       make stack [start, end, str]
         x@#@k  push range(start, end), explode string, make list of stack
```
Map 2:
```
i@X@M
i@X     flatten, swap, discard (discard the string)
   @M   swap, max (take maximum element from range)
```
Map 3:
```
iZi  flatten, zip, flatten (make list of [index, char] pairs)
```
Map 4:
```
i╜T╗  flatten, push reg 0, set element, push to reg 0
```
In a nutshell, this program makes a string with `n` spaces, where `n` is the minimum length the string can be based on the input. It determines the index in the result string of each character in each slice, and sets the character in the result string at that index to the character.
[Answer]
# Python, 91 bytes.
Saved 1 byte thanks to cat.
It's a bit long. I'll golf it down more in a bit.
```
def f(x):r={j+i:q for(i,s)in x for j,q in enumerate(s)};return"".join(map(r.get,sorted(r)))
```
[Answer]
## Python, ~~119~~ 115 bytes
```
def f(x,s=""):
 x.sort()
 for e in x:
  a=e[0];b=e[1]
  for i,c in enumerate(b):
   if len(s)<=(i+a):s+=c
 return s
```
### Test cases
[![enter image description here](https://i.stack.imgur.com/oBxAD.png)](https://i.stack.imgur.com/oBxAD.png)
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 16 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
ñÎrÈ+S hYÌYg)x}P
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=8c5yyCtTIGhZzFlnKXh9UA&input=WwpbWzIsICJDRyJdLCBbMCwgIlBQIl0sIFsxLCAiUEMiXV0KW1swLCAiZm9vYmFyYmF6Il1dCltbMCwgImZvb2JhciJdLCBbNiwgImJheiJdXQpbWzIsICJvYiJdLCBbNSwgInJiYSJdLCBbMCwgImZvb2JhIl0sIFs4LCAieiJdXQpbWzAsICJmbyJdLCBbMCwgImZvb2JhIl0sIFswLCAiZm9vYmFyYmF6Il1dCl0tbVI)
Explanation:
```
ñÎrÈ+S hYÌYg)x}P
               P # Starting with an empty string X
  r           }  # For each item Y in:
ñ                #  Input sorted by 
 Î               #  The first item in each sub-array
   È             # Apply the following to X:
    +S           #  Add a space to the end
       h    )    #  Overwrite:
          Yg     #   Starting index is the first item in Y
        YÌ       #   New characters are the last item in Y
             x   #  Trim any leftover whitespace
```
Unfortunately `h` wraps its index, so attempting to write new characters at the end of a string with it instead writes them back at the start.
[Answer]
# [QBasic](https://en.wikipedia.org/wiki/QBasic), ~~127~~ 114 bytes
```
INPUT n
FOR j=1TO n
INPUT i
LINE INPUT s$
l=LEN(s$)
e=LEN(r$)-i-l
r$=r$+SPACE$(e*(e<0))
MID$(r$,i+1,l)=s$
NEXT
?r$
```
You can try it at [Archive.org](https://archive.org/details/msdos_qbasic_megapack). The input format is: first, [the number of slices](https://codegolf.meta.stackexchange.com/a/24639/16766); then, for each slice, the (0-based) index and the string on separate lines. Here's what running the first test case would look like:
```
? 3
? 2
CG
? 0
PP
? 1
PC
PPCG
```
### Explanation
```
INPUT n
```
Input the number of slices as `n`.
```
FOR j = 1 TO n
...
NEXT
```
Loop `n` times:
```
INPUT i
```
Input the starting index of the next slice as `i`.
```
LINE INPUT s$
```
Input the contents of the slice as `s$`. `LINE INPUT` is used to make sure that any printable ASCII character can be included in the input; if characters like `,` and `"` could be excluded, the two input statements could be combined as `INPUT i,s$`, saving 11 bytes.
```
l = LEN(s$)
```
Store the length of the slice as `l`.
```
e=LEN(r$)-i-l
```
The result string is stored in `r$` (initially empty by default). If merging this slice would extend `r$` beyond its current length, the number of characters we would need to add is given by `i` plus `l` minus the current length of `r$`. Calculate this amount, negated (see below for why), and store it as `e`.
```
r$ = r$ + SPACE$(e * (e < 0))
```
Pad `r$` as necessary by appending spaces to it. Comparison operators in QBasic return -1 for true and 0 for false. Thus, if `e < 0`, we append `-e` spaces; otherwise, we append `0` spaces.
```
MID$(r$, i + 1, l) = s$
```
Overwrite `l` characters of `r$`, starting at index `i + 1` (since `MID$` uses 1-based indexing), with the contents of `s$`.
```
PRINT r$
```
After the loop finishes, print the final value of `r$`.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 13 bytes
```
meSd.Tm+*;hde
```
[Test suite](https://pythtemp.herokuapp.com/?code=meSd.Tm%2B%2a%3Bhde&test_suite=1&test_suite_input=%5B%5B2%2C+%22CG%22%5D%2C+%5B0%2C+%22PP%22%5D%2C+%5B1%2C+%22PC%22%5D%5D%0A%5B%5B0%2C+%22foobarbaz%22%5D%5D%0A%5B%5B0%2C+%22foobar%22%5D%2C+%5B6%2C+%22baz%22%5D%5D%0A%5B%5B2%2C+%22ob%22%5D%2C+%5B5%2C+%22rba%22%5D%2C+%5B0%2C+%22fooba%22%5D%2C+%5B8%2C+%22z%22%5D%5D%0A%5B%5B0%2C+%22fo%22%5D%2C+%5B0%2C+%22fooba%22%5D%2C+%5B0%2C+%22foobarbaz%22%5D%5D&debug=0)
Takes input as a list of elements of the structure `[index, string]`. Outputs a list of characters.
##### Explanation:
```
meSd.Tm+*;hde   | Full code
meSd.Tm+*;hdedQ | with implicit variables
----------------+------------------------------------------------
      m       Q | Map over the input:
       +    ed  |  Prepend the string with
        *;hd    |   <index> spaces
    .T          | Ragged transpose
meSd            | Take the lexicographically last element of each
```
[Answer]
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), 7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ε`ú}ζ€à
```
Output as a list of characters.
[Try it online](https://tio.run/##MzBNTDJM/f//3NaEw7tqz2171LTm8IL//6OjjXSU8pOUYnWiTXWUipISQSwDHaW0/HwI20JHqUopNhYA) or [verify all test cases](https://tio.run/##MzBNTDJM/V9Waa@k8KhtkoKSfeX/c1sTDu@qPbftUdOawwv@u9h7KSloHN6vqaTzPzo62khHydldKVYn2kBHKSAAxDAEMpyVYoEskFhafn5SYlFSYhWaCEilmY4SXAJoTn4SSNBURwmoHGoiWC2IbaGjhGwCujSaRbEA).
**Explanation:**
Uses the legacy version of 05AB1E instead of the new one for two reasons:
1. The zip/transpose builtins work on a list of strings, whereas the new version would require a list of lists of characters.
2. The minimum/maximum builtins work on characters (using their codepoint), which doesn't work in the new version.
```
ε     # Map over each pair of the (implicit) input-list:
 `    #  Pop the pair and push both values separated to the list
  ú   #  Pad the string with the integer amount of leading spaces
}ζ    # After the map: zip/transpose the strings, swapping rows/columns, using a default
      # space " " filler if strings are of unequal length
  €   # Map over each string
   à  #  Only leave its maximum character
      # (after which the resulting list of characters is output implicitly)
```
[Answer]
## CJam, 26 bytes
```
q~{~0c*\+}%{.{s\s|}}*e_0c-
```
[Try it online!](http://cjam.aditsu.net/#code=q~%7B~0c*%5C%2B%7D%25%7B.%7Bs%5Cs%7C%7D%7D*e_0c-&input=%5B%5B%22CG%222%5D%5B%22PP%220%5D%5B%22PC%221%5D%5D%20). Takes input in form `[["CG"2]["PP"0]["PC"1]]`.
Explanation:
```
q~           Read and eval input
{~0c*\+}%    Convert input strings into workable format
{      }%     Map onto each input
 ~            Evaluate
  0c          Null character
    *\+       Multiply by input number and concat to string
{.{s\s|}}*   Combine strings
{       }*    Fold array
 .{    }       Vectorize, apply block to corresponding elements of arrays
   s\s         Convert elements to strings
      |        Set Union
e_0c-        Remove null characters
```
[Answer]
## R, 181 bytes
```
n=nchar;m=matrix(scan(,'raw'),ncol=2,byrow=T);w=rep('',max(n(m[,2])+(i<-strtoi(m[,1]))));for(v in 1:nrow(m)) w[seq(i[v]+1,l=n(m[v,2]))]=unlist(strsplit(m[v,2],''));cat("",w,sep="")
```
With line breaks:
```
n=nchar
m=matrix(scan(,'raw'),ncol=2,byrow=T)
w=rep('',max(n(m[,2])+(i<-strtoi(m[,1]))))
for(v in 1:nrow(m)) w[seq(i[v]+1,l=n(m[v,2]))]=unlist(strsplit(m[v,2],''))
cat("",w,sep="")
```
Works in R Gui (single line one, or sourcing for the multi-line one) but not in ideone, example:
```
> n=nchar;m=matrix(scan(,'raw'),ncol=2,byrow=T);w=rep('',max(n(m[,2])+(i<-strtoi(m[,1]))));for(v in 1:nrow(m)) w[seq(i[v]+1,l=n(m[v,2]))]=unlist(strsplit(m[v,2],''));cat("",w,sep="")
1: 2 ob 5 rba 0 fooba 8 z
9: 
Read 8 items
foobarbaz
```
Note on the input method:
> 
> or simply a string consisting of the number, a space, and then the slice.
> 
> 
> 
I assume I comply with this part of the spec with this kind of input, it can be given on multiple lines, this has no impact as long as there a blank line to end the input.
I think 2 chars can be saved by removing the +1 and using 1 based indexing but I started with challenge input.
[Answer]
# C, 110 bytes
```
c,i,j;char s[99];main(){while(~scanf("%i ",&i))for(;(c=getchar())>10;s[i++]=c);for(;s[j]>10;putchar(s[j++]));}
```
This program takes the slice after its index in one line of input each.
Ungolfed:
```
c,i,j;char s[99];
main(){
    while(~scanf("%i ",&i))
        for(;(c=getchar())>10;s[i++]=c);
    for(;s[j]>10;putchar(s[j++]));
}
```
Test on [ideone.com](http://ideone.com/LMp8xg)
[Answer]
## Lua, 113 bytes
```
z=loadstring("return "..io.read())()table.sort(z,function(a,b)return a[1]<b[1]end)for a=1,#z do print(z[a][2])end
```
This is probably some of the more secure code I've written. The idea is simple. The user will enter an array formatted as so: `{{1, "1"}, {3, "3"}, {2, "2"}}` and then the table will be sorted by the first index and the second index will be printed.
]