__author__ = 'Devesh Bajpai'

'''
https://codeforces.com/problemset/problem/1339/B

Solution: Sort the array. Keep 2 pointers left and right. Take the pair of elements of these pointed elements
in the result array. Move the left leftwards and right rightwards. This ensures the net distance on the
number line is smallest, thereby agreeing to the constraint of absolute differences of pair elements.
'''

def solve(n, arr):

    arr.sort()

    left = n/2 - 1
    right = n/2

    result = [None] * n
    i = 0

    while left >= 0 and right < n:

        result[i] = arr[left]
        i += 1
        left -= 1
        result[i] = arr[right]
        i += 1
        right += 1

    return result

if __name__ == "__main__":

    t = int(raw_input())

    results = list()
    for _ in xrange(0, t):
        n = int(raw_input())
        arr = map(int, raw_input().split(" "))
        results.append(solve(n, arr))

    for result in results:
        print result


__author__ = 'Devesh Bajpai'

'''
https://codeforces.com/problemset/problem/1339/B

Solution: Sort the array. Keep 2 pointers left and right. Take the pair of elements of these pointed elements
in the result array. Move the left leftwards and right rightwards. This ensures the net distance on the
number line is smallest, thereby agreeing to the constraint of absolute differences of pair elements.

For odd length arrays, we keep the middle element as the first element in the result array since it cannot
be paired. And then we start from the pointers movement as mentioned above.
'''

def solve(n, arr):

    arr.sort()

    result = [None] * n

    if n % 2 == 0:
        left = n/2 - 1
        right = n/2
        i = 0
    else:
        left = (n-1)/2 - 1
        right = (n-1)/2
        result[0] = arr[n/2]
        i = 1

    while left >= 0 and right < n:

        result[i] = arr[left]
        i += 1
        left -= 1

        result[i] = arr[right]
        i += 1
        right += 1

    return " ".join(str(_) for _ in result)

if __name__ == "__main__":

    t = int(raw_input())

    results = list()
    for _ in xrange(0, t):
        n = int(raw_input())
        arr = map(int, raw_input().split(" "))
        results.append(solve(n, arr))

    for result in results:
        print result


__author__ = 'Devesh Bajpai'

'''
https://codeforces.com/problemset/problem/1339/B

Solution: Sort the array. Keep 2 pointers left and right. Take the pair of elements of these pointed elements
in the result array. Move the left leftwards and right rightwards. This ensures the net distance on the
number line is smallest, thereby agreeing to the constraint of absolute differences of pair elements.

For odd length arrays, we keep the middle element as the first element in the result array since it cannot
be paired. And then we start from the pointers movement as mentioned above.
'''

def solve(n, arr):

    arr.sort()

    result = [None] * n

    if n % 2 == 0:
        left = n/2 - 1
        right = n/2
        i = 0
    else:
        left = (n-1)/2 - 1
        right = (n-1)/2 + 1
        result[0] = arr[n/2]
        i = 1

    while left >= 0 and right < n:

        result[i] = arr[left]
        i += 1
        left -= 1

        result[i] = arr[right]
        i += 1
        right += 1

    return " ".join(str(_) for _ in result)

if __name__ == "__main__":

    t = int(raw_input())

    results = list()
    for _ in xrange(0, t):
        n = int(raw_input())
        arr = map(int, raw_input().split(" "))
        results.append(solve(n, arr))

    for result in results:
        print result


__author__ = 'Devesh Bajpai'

'''
https://codeforces.com/problemset/problem/1339/B

Solution: Sort the array. Keep 2 pointers left and right. Take the pair of elements of these pointed elements
in the result array. Move the left leftwards and right rightwards. This ensures the net distance on the
number line is smallest, thereby agreeing to the constraint of absolute differences of pair elements.
'''

def solve(n, arr):

    arr.sort()

    left = n/2 - 1
    right = n/2

    result = [None] * n
    i = 0

    while left >= 0 and right < n:

        result[i] = arr[left]
        i += 1
        left -= 1
        result[i] = arr[right]
        i += 1
        right += 1

    return " ".join(str(_) for _ in result)

if __name__ == "__main__":

    t = int(raw_input())

    results = list()
    for _ in xrange(0, t):
        n = int(raw_input())
        arr = map(int, raw_input().split(" "))
        results.append(solve(n, arr))

    for result in results:
        print result


__author__ = 'Devesh Bajpai'

'''
https://codeforces.com/problemset/problem/1339/B

Solution: Sort the array. Keep 2 pointers left and right. Take the pair of elements of these pointed elements
in the result array. Move the left leftwards and right rightwards. This ensures the net distance on the
number line is smallest, thereby agreeing to the constraint of absolute differences of pair elements.
'''

def solve(n, arr):

    arr.sort()

    left = n/2 - 1
    right = n/2

    result = [None] * n
    i = 0

    while left >= 0 and right < n:

        result[i] = arr[left]
        i += 1
        left -= 1
        result[i] = arr[right]
        i += 1
        right += 1

    return "[" + ", ".join(str(_) for _ in result) + "]"

if __name__ == "__main__":

    t = int(raw_input())

    results = list()
    for _ in xrange(0, t):
        n = int(raw_input())
        arr = map(int, raw_input().split(" "))
        results.append(solve(n, arr))

    for result in results:
        print result


t = int(raw_input())
for i in xrange(t):
    n = int(raw_input())
    A = map(int, raw_input().split())
    A.sort()
    B = [A[0]]
    C = []
    if n%2 == 0:
        for j in xrange(1,n/2):
            B.append(A[-j])
            B.append(A[j])
        B.append(A[n/2])
    else:
        for k in xrange(1,(n+1)/2):
            B.append(A[-k])
            B.append(A[k])
    for g in xrange(1,n+1):
        C.append(B[-g])
    print ' '.join(str(x) for x in C)


import math
for _ in range(input()):
    n=input()
    l=map(int,raw_input().split())
    l.sort()
    i=0
    j=n-1
    a=[]
    while i<j:
        a.append(l[j])
        a.append(l[i])
        i+=1
        j-=1
    if n%2==1:
        a+=[l[i]]
    for i in range(n):
        print a[n-i-1],
    print


from sys import stdin,stdout
from collections import defaultdict as dd
read,write = stdin.readline,stdout.write
iread = lambda: int(read())
sread = lambda: read().strip()
spread = lambda func=int: map(func,read().split())

t = iread()
for _ in xrange(t):
    n = iread()
    arr = spread()
    arr.sort()
    rev_arr = arr[::-1]

    res = []
    if n&1:
        res.append(arr[n/2])
    for i in xrange(n/2):
        res.append(rev_arr[n/2 - (i+1)])
        res.append(arr[n/2 -(i+1)])
    print ' '.join(map(str,res))


def ints():
    return map(int, raw_input().split())

num_cases, = ints()

def solve(n, a):
    a.sort()
    b = a[:n/2][::-1]
    c = a[n/2:]
    ret = []
    for i in range(n/2):
        ret.append(c[i])
        ret.append(b[i])
    if n % 2 == 1:
        ret.append(c[-1])
    return ret

for case_num in xrange(1, num_cases + 1):
    n, = ints()
    a = ints()
    ans = solve(n, a)
    print "{}".format(' '.join(map(str, ans)))


for _ in range(input()):
    n = input()
    a = map(int,raw_input().split())
    a.sort()
    ans = []
    for i in range(n/2):
        ans.append(a[i])
        ans.append(a[n-1-i])
    if n%2!=0:
        ans.append(a[n/2])
    ans = ans[::-1]
    for x in ans:
        print x,
    print


import sys

__author__ = 'ratmir'

[t] = [int(x) for x in sys.stdin.readline().split()]

for ti in range(0, t):
    [n] = [int(x) for x in sys.stdin.readline().split()]
    a = [int(x) for x in sys.stdin.readline().split()]
    a = sorted(a)

    # if len(a) % 2 == 1:
    b = []
    middle = (len(a) / 2)
    b = [a[middle]]
    #print a
    #print middle
    for i in range(1, middle + len(a) % 2):
        b.append(a[middle - i])
        b.append(a[middle + i])

    if len(a) % 2 == 0:
        b.append(a[0])

    print(''.join('{} '.format(k) for k in b))


for _ in xrange(int(raw_input())):
    n = input()
    a = map(int, raw_input().split())
    a.sort()
    for x, y in zip(a[n/2:], a[:n/2][::-1]):
        print x, y,
    print a[-1] if n % 2 else ""


#include<stdio.h>
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    int L[n1], R[n2];

    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {

        int m = l+(r-l)/2;

        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}
int main()
{
    int t,n;
    scanf("%d",&t);

    while(t--)
    {
       scanf("%d", &n);
        int arr[n];
        int arb[n];

        for(int i=0;i<n;i++)
            scanf("%d",&arr[i]);

            mergeSort(arr,0,n);
            int k;

                if(n%2==0)
                {
                    k=n-1;
                    for(int i=0;i<n/2;i++)
                         {
                             arb[k--]=arr[n-i-1];
                             arb[k--]=arr[i];
                         }
                }
                else
                    {
                        k=n-1;
                        arb[0]=arr[n/2];
                     for(int i=0;i<n/2;i++)
                         {
                             arb[k--]=arr[n-i-1];
                             arb[k--]=arr[i];
                         }

                    }
            for(int i=0;i<n;i++)
            printf("%d ",arb[i]);
            printf("\n");
    }

return 0;
}


#include<stdio.h>
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    int L[n1], R[n2];

    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {

        int m = l+(r-l)/2;

        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}
int main()
{
    int t,n;
    scanf("%d",&t);

    while(t--)
    {
       scanf("%d", &n);
        int arr[n];
        int arb[n];

        for(int i=0;i<n;i++)
            scanf("%d",&arr[i]);
           // for(int i=0;i<n;i++)
          // printf("%d ",arr[i]);

            mergeSort(arr,0,n-1);
            //  for(int i=0;i<n;i++)
          //  printf("%d ",arr[i]);
            int k;

                if(n%2==0)
                {
                    k=n-1;
                    for(int i=0;i<n/2;i++)
                         {
                             arb[k--]=arr[n-i-1];
                             arb[k--]=arr[i];
                         }
                }
                else
                    {
                        k=n-1;
                        arb[0]=arr[n/2];
                     for(int i=0;i<n/2;i++)
                         {
                             arb[k--]=arr[n-i-1];
                             arb[k--]=arr[i];
                         }

                    }
            for(int i=0;i<n;i++)
            printf("%d ",arb[i]);
            printf("\n");
    }

return 0;
}


#include<stdio.h>
#include <stdlib.h>
int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b);
}
void print(int *a,int n)
{
    int i;
    for ( i = 0; i < n; i++)
    {
        printf("%d ",a[i]);
    }

}
int main()
{
    int t,i,j,n,k;
    scanf("%d",&t);
    while (t--)
    {
        scanf("%d",&n);
        int a[n];
        int s[n];
        for ( i = 0; i < n; i++)
        {
            scanf("%d",&a[i]);
        }
        qsort(a,n, sizeof(int), cmpfunc);
        j=0;
        for (i=n-2; i>=0; i=i-2)
        {
            s[i]=a[j];
            j++;
       }
       j=n-1;
       for (k=n-1; k>=0; k=k-2)
        {
            s[k]=a[j];
            j--;
       }
        print(s,n);

    }

}


#include<stdio.h>
#include<stdlib.h>
int cmpfunc (const void * a, const void * b)
{
    if( *(long long int*)a - *(long long int*)b < 0 )
        return -1;
    if( *(long long int*)a - *(long long int*)b > 0 )
        return 1;
    return 0;
}
void main()
{
    long long int i,j,t,n,arr[100005],p[100005]={0},k,indexMin;
    scanf("%lld",&t);
    for(i=0;i<t;i++)
    {
        scanf("%lld",&n);
        for(j=0;j<n;j++)
        {
            scanf("%lld",&arr[j]);
        }
        qsort(arr,n,sizeof(long long int),cmpfunc);
        if(n%2==0)
        {
            k=n-1;
            for(j=0;j<n/2;j++)
            {
                p[k]=arr[j];
                k-=2;
            }
            k=0;
            for(j=n/2;j<n;j++)
            {
                p[k]=arr[j];
                k+=2;
            }
        }
        else if(n%2!=0)
        {
            k=n-1;
            for(j=0;j<=n/2;j++)
            {
                p[k]=arr[j];
                k-=2;
            }
            k=1;
            for(j=n/2+1;j<n;j++)
            {
                p[k]=arr[j];
                k+=2;
            }
        }
        for(j=0;j<n;j++)
                printf("%lld ",p[j]);
    }
    exit(0);
}


#include<stdio.h>
#include<stdlib.h>
int comp1(const void* a, const void* b) //升序
{
	return *(int*)a - *(int*)b;
}
int a[10005];
int main(void)
{
	int t;
	scanf("%d", &t);
	int n;
	int k, j;
	while (t--)
	{
		scanf("%d", &n);
		for (int i = 0; i < n; i++)
			scanf("%d", &a[i]);
		qsort(a, n, sizeof(int), comp1);
		k = n / 2;
		j = k;
		for (int i = 0; i < n; i++)
		{
			printf("%d ", a[i]);
			if (i % 2 == 0)
				j = k - i / 2 - 1;
			else
				j = k + i / 2 + 1;
		}
		printf("\n");
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int comp1(const void* a, const void* b) //升序
{
	return *(int*)a - *(int*)b;
}
int a[10005];
int main(void)
{
	int t;
	scanf("%d", &t);
	int n;
	int k, j;
	while (t--)
	{
		scanf("%d", &n);
		for (int i = 0; i < n; i++)
			scanf("%d ", &a[i]);
		qsort(a, n, sizeof(int), comp1);
		k = n / 2;
		j = k;
		for (int i = 0; i < n; i++)
		{
			printf("%d", a[i]);
			if (i % 2 == 0)
				j = k - i / 2 - 1;
			else
				j = k + i / 2 + 1;
		}
		printf("\n");
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int comp1(const void* a, const void* b) //升序
{
	return *(int*)a - *(int*)b;
}
int a[10005];
int main(void)
{
	int t;
	scanf("%d", &t);
	int n;
	int k, j;
	while (t--)
	{
		scanf("%d", &n);
		for (int i = 0; i < n; i++)
			scanf("%d", &a[i]);
		qsort(a, n, sizeof(int), comp1);
		k = n / 2;
		j = k;
		for (int i = 0; i < n; i++)
		{
			printf("%d ", a[j]);
			if (i % 2 == 0)
				j = k - i / 2 - 1;
			else
				j = k + i / 2 + 1;
		}
		printf("\n");
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int comp1(const void* a, const void* b) //升序
{
	return *(int*)a - *(int*)b;
}
int a[10005];
int main(void)
{
	int t;
	scanf("%d", &t);
	int n;
	int k, j;
	while (t--)
	{
		scanf("%d", &n);
		for (int i = 0; i < n; i++)
			scanf("%d", &a[i]);
		qsort(a, n, sizeof(int), comp1);
		k = n / 2;
		j = k;
		for (int i = 0; i < n; i++)
		{
			printf("%d", a[i]);
			if (i % 2 == 0)
				j = k - i / 2 - 1;
			else
				j = k + i / 2 + 1;
		}
		printf("\n");
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int comp1(const void* a, const void* b) //升序
{
	return *(int*)a - *(int*)b;
}
int a[100005];
int main(void)
{
	int t;
	scanf("%d", &t);
	int n;
	int k, j;
	while (t--)
	{
		scanf("%d", &n);
		for (int i = 0; i < n; i++)
			scanf("%d", &a[i]);
		qsort(a, n, sizeof(int), comp1);
		k = n / 2;
		j = k;
		for (int i = 0; i < n; i++)
		{
			printf("%d ", a[j]);
			if (i % 2 == 0)
				j = k - i / 2 - 1;
			else
				j = k + i / 2 + 1;
		}
		printf("\n");
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

void merge(long long int arr[], long long int l, long long int m, long long int r)
{
    long long int i, j, k;
    long long int n1 = m - l + 1;
    long long int n2 =  r - m;

    /* create temp arrays */
    long long int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(long long int arr[], long long int l, long long int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        long long int m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}

int main()
{
	long long int t;
	scanf("%lld", &t);

	do
	{
		long long int n;
		scanf("%lld", &n);

		long long int a[n];
		long long int i;
		for ( i = 0; i < n ; ++i )
		{
			scanf("%lld", &a[i]);
		}

		mergeSort(a,0,n-1);
		long long int sol[n];
		long long int index = 0;
		for ( i = 0; i < (n+1)/2; ++i )
		{
			sol[index] = a[i];
			++index;
			if ( index < n )
			{
				sol[index] = a[n-i-1];
				++index;
			}
		}
		/*
		for ( i = 0; i < n; ++i )
		{
			printf("%lld ", sol[i]);
		}
		printf("\n");
		*/
		for ( i = n-1; i >= 0; --i )
		{
			printf("%lld ", sol[i]);
		}
		printf("\n");

		--t;
	} while ( t != 0 );
	//system("pause");
}


#include <stdio.h>
#include <string.h>
#include <math.h>
void merge(int a[],int l,int r)
{
	int mid=(r+l)/2,x=l,y=mid+1,b[r-l+1],z=0;
	for(int i=l;i<=r;i++)
	{
		if(a[x]<=a[y]&&x<=mid)
			b[z++]=a[x++];
			else if(y<=r)
			b[z++]=a[y++];
			else
			b[z++]=a[x++];
	}
	for(int i=l;i<=r;i++)
	a[i]=b[i-l];
}
void msort(int a[],int l,int r)
{
	int mid=(r+l)/2;
	if(l>=r)
	return;
	msort(a,l,mid);
	msort(a,mid+1,r);
	merge(a,l,r);
}
int main()
{
	int i,j,k,n,m,x,y,z,t;
	scanf("%d",&t);
	for(int z1=0;z1<t;z1++)
	{
		scanf("%d",&n);
		int a[n];
		for(i=0;i<n;i++)
		scanf("%d",&a[i]);
		msort(a,0,n-1);
		x=n/2;y=n/2-1;
	for(i=0;i<n;i++)
	{
		if(i%2==0)
		printf("%d ",a[x++]);
		else
		printf("%d ",a[y--]);
	}
	printf("\n");
	}

}


#include <stdio.h>
#include <stdlib.h>

int cmp(const   void    *a,const    void    *b)
{
    return  *(int   *)a - *(int *)b;
}

int main()
{
    int t, n,i,j,mid;
    int a[100005];
    scanf("%d",&t);
    while(t--)
    {
       scanf("%d",&n);
       for(i = 0; i < n; i++ )
           scanf("%d",&a[i]);
       qsort(a,n,sizeof(a[i] * n),cmp);

       for( i = n / 2 - 1 , j = n / 2 ;  j < n; i--, j++)
       {
            printf("%d ",a[j]);
           if(i >= 0)
            printf("%d ",a[i]);

       }
       printf("\n");
    }
    return  0;
}


#include <stdio.h>
#include <stdlib.h>

int cmp(const   void    *a,const    void    *b)
{
    return  *(int   *)a - *(int *)b;
}

int main()
{
    int t, n,i,j,mid;
    long long int a[100001];
    scanf("%d",&t);
    while(t--)
    {
       scanf("%d",&n);
       for(i = 0; i < n; i++ )
       {
           scanf("%d",&a[i]);
       }
       qsort(a,n,sizeof(a),cmp);
       for( i = n / 2 - 1 , j = n / 2 ;  j < n; i--, j++)
       {
            printf("%d ",a[j]);
           if(i >= 0)
            printf("%d ",a[i]);

       }
       printf("\n");
    }
    return  0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int t, n,i,j,mid;
    long long int a[100001];
    scanf("%d",&t);
    while(t--)
    {
       scanf("%d",&n);
       for(i = 0; i < n; i++ )
       {
           scanf("%d",&a[i]);
       }
       for(i = 0; i < n - 1; i++)
        for(j = i + 1; j < n; j++)
       {
           if(a[i] > a[j])
           {
               mid = a[i];
               a[i] = a[j];
               a[j] = mid;
           }
       }

       for( i = n / 2 - 1 , j = n / 2 ; i >= 0 || j < n; i--, j++)
       {
           if(j < n)
            printf("%d ",a[j]);
           if(i >= 0)
            printf("%d ",a[i]);

       }
       printf("\n");
    }
    return  0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int t, n,i,j,mid;
    long long int a[100001];
    scanf("%d",&t);
    while(t--)
    {
       scanf("%d",&n);
       for(i = 0; i < n; i++ )
       {
           scanf("%lld",&a[i]);
       }
       for(i = 0; i < n - 1; i++)
        for(j = i + 1; j < n; j++)
       {
           if(a[i] > a[j])
           {
               mid = a[i];
               a[i] = a[j];
               a[j] = mid;
           }
       }

       for( i = n / 2 - 1 , j = n / 2 ; i >= 0 || j < n; i--, j++)
       {
           if(j < n)
            printf("%lld ",a[j]);
           if(i >= 0)
            printf("%lld ",a[i]);

       }
       printf("\n");
    }
    return  0;
}


#include <stdio.h>
#include <stdlib.h>

void quicksort(int arr[], int l, int r)
{
    // Base case: No need to sort arrays of length <= 1
    if (l >= r)
    {
        return;
    }

    // Choose pivot to be the last element in the subarray
    int pivot = arr[r];

    // Index indicating the "split" between elements smaller than pivot and
    // elements greater than pivot
    int cnt = l;

    // Traverse through array from l to r
    for (int i = l; i <= r; i++)
    {
        // If an element less than or equal to the pivot is found...
        if (arr[i] <= pivot)
        {
            // Then swap arr[cnt] and arr[i] so that the smaller element arr[i]
            // is to the left of all elements greater than pivot
            arr[cnt] = arr[cnt] + arr[i] - (arr[i] = arr[cnt]);
            // Make sure to increment cnt so we can keep track of what to swap
            // arr[i] with
            cnt++;
        }
    }

    // NOTE: cnt is currently at one plus the pivot's index
    // (Hence, the cnt-2 when recursively sorting the left side of pivot)
    quicksort(arr, l, cnt - 2); // Recursively sort the left side of pivot
    quicksort(arr, cnt, r);     // Recursively sort the right side of pivot
}

int main()
{
    int t, n, pivot, d;
    int *A;

    scanf("%d", &t);

    for (int i = 0; i < t; ++i)
    {
        scanf("%d", &n);
        A = (int *)malloc(n * sizeof(int));
        for (int j = 0; j < n; ++j)
            scanf("%d", A + j);
        quicksort(A, 0, n - 1);

        pivot = n / 2 - (n % 2 == 0 ? 1 : 0);
        d = 1;
        printf("%d ", A[pivot]);
        while (d <= n / 2)
        {
            printf("%d ", A[pivot + d]);
            if (pivot - d > -1)
                printf("%d ", A[pivot - d]);
            d++;
        }

        free(A);
        A = NULL;
    }
}


#include <stdio.h>
#include <stdlib.h>

void quicksort(long int arr[], int l, int r)
{
    // Base case: No need to sort arrays of length <= 1
    if (l >= r)
    {
        return;
    }

    // Choose pivot to be the last element in the subarray
    long int pivot = arr[r];

    // Index indicating the "split" between elements smaller than pivot and
    // elements greater than pivot
    int cnt = l;

    // Traverse through array from l to r
    for (int i = l; i <= r; i++)
    {
        // If an element less than or equal to the pivot is found...
        if (arr[i] <= pivot)
        {
            // Then swap arr[cnt] and arr[i] so that the smaller element arr[i]
            // is to the left of all elements greater than pivot
            arr[cnt] = arr[cnt] + arr[i] - (arr[i] = arr[cnt]);
            // Make sure to increment cnt so we can keep track of what to swap
            // arr[i] with
            cnt++;
        }
    }

    // NOTE: cnt is currently at one plus the pivot's index
    // (Hence, the cnt-2 when recursively sorting the left side of pivot)
    quicksort(arr, l, cnt - 2); // Recursively sort the left side of pivot
    quicksort(arr, cnt, r);     // Recursively sort the right side of pivot
}

int main()
{
    int t, n, pivot, d;
    long int *A;

    scanf("%d", &t);

    for (int i = 0; i < t; ++i)
    {
        scanf("%d", &n);
        A = (int *)malloc(n * sizeof(int));
        for (int j = 0; j < n; ++j)
            scanf("%ld", A + j);
        quicksort(A, 0, n - 1);

        pivot = n / 2 - (n % 2 == 0 ? 1 : 0);
        d = 1;
        printf("%ld ", A[pivot]);
        while (d <= n / 2)
        {
            printf("%ld ", A[pivot + d]);
            if (pivot - d > -1)
                printf("%ld ", A[pivot - d]);
            d++;
        }

        free(A);
        A = NULL;
    }
}


#include <stdio.h>
#include <stdlib.h>

void merge(long int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 = r - m;

    /* create temp arrays */
    long int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1 + j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(long int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l + (r - l) / 2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m + 1, r);

        merge(arr, l, m, r);
    }
}

int main()
{
    int t, n, pivot, d;
    long int *A;

    scanf("%d", &t);

    for (int i = 0; i < t; ++i)
    {
        scanf("%d", &n);
        A = (long int *)malloc(n * sizeof(int));
        for (int j = 0; j < n; ++j)
            scanf("%ld", A + j);
        mergeSort(A, 0, n - 1);

        pivot = n / 2 - (n % 2 == 0 ? 1 : 0);
        d = 1;
        printf("%ld ", A[pivot]);
        while (d <= n / 2)
        {
            printf("%ld ", A[pivot + d]);
            if (pivot - d > -1)
                printf("%ld ", A[pivot - d]);
            d++;
        }
        printf("\n");

        free(A);
        A = NULL;
    }
}


#include<stdio.h>
#include<stdlib.h>

void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    int L[n1], R[n2];

    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        int m = l+(r-l)/2;

        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}

int main()
{
  int t, n, a[1000],result_arr[10000],i,j,k,arr_size;

  scanf("%d",&t);

  while(t--)
  {
      scanf("%d",&n);

      for(i = 0; i<n; i++)
      {
          scanf("%d",&a[i]);
      }
      //sort the array now
      arr_size =  n;
      mergeSort(a, 0, arr_size - 1);

      //then do this activity

      k=n-1;
      for(i=0, j=n-1; i<n/2; i++,j--)
      {
          result_arr[k--] = a[j];
          result_arr[k--] = a[i];
      }
      if(n%2 != 0)
        result_arr[0] = a[i];
      printf("%d", result_arr[0]);
      for(i=1; i<n; i++)
      {
          printf(" %d", result_arr[i]);
      }
      printf("\n");
  }
}


#include<stdio.h>
#include<stdlib.h>

void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    int L[n1], R[n2];

    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        int m = l+(r-l)/2;

        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}

int main()
{
  int t, n, a[100000],result_arr[100000],i,j,k,arr_size;

  scanf("%d",&t);

  while(t--)
  {
      scanf("%d",&n);

      for(i = 0; i<n; i++)
      {
          scanf("%d",&a[i]);
      }
      //sort the array now
      arr_size =  n;
      mergeSort(a, 0, arr_size - 1);

      //then do this activity

      k=n-1;
      for(i=0, j=n-1; i<n/2; i++,j--)
      {
          result_arr[k--] = a[j];
          result_arr[k--] = a[i];
      }
      if(n%2 != 0)
        result_arr[0] = a[i];
      printf("%d", result_arr[0]);
      for(i=1; i<n; i++)
      {
          printf(" %d", result_arr[i]);
      }
      printf("\n");
  }
}


#include<stdio.h>
void swap(int* a, int* b)
{
    int t= *a;
    *a = *b;
    *b = t;
}
int partition(int a[], int low, int high)
{
    int pivot=a[high];
    int i=low-1;
    for(int j=low;j<=high-1;j++)
    {
        if(a[j]<pivot)
        {
            i++;
            swap(&a[i],&a[j]);
        }
    }
    swap(&a[i+1],&a[high]);
    return i+1;
}
void quicksort(int a[], int low, int high)
{
   if(low<high)
   {
       int q=partition(a, low, high);
    quicksort(a, low, q-1);
    quicksort(a, q+1, high);
}
}
int main()
{
    int t,p;
    scanf("%d",&t);
    for(p=0;p<t;p++)
    {
        int n,i,j;
        scanf("%d",&n);
        int arr[n],b[n];
        for(i=0;i<n;i++)
        {
           scanf("%d",&arr[i]);
        }
        swap(&arr[n-1],&arr[(n/2)-2]);
        quicksort(arr, 0, n-1);
        int m;
       if(n%2==0)
       {
           m=n/2;
       }
       else{m=(n+1)/2;}
       for(i=0,j=1;i<n,j<=m;i+=2,j++)
       {
           b[i]=arr[m-j];
       }
       for(i=1,j=0;i<n,j<=m;i+=2,j++)
       {
           b[i]=arr[m+j];
       }
       for(i=0;i<n;i++)
       {
           printf("%d ",b[i]);
       }
         printf("\n");
    }
}


#include<stdio.h>
void swap(int* a, int* b)
{
    int t= *a;
    *a=*b;
    *b=t;
}
void heapify(int arr[], int n, int i)
{
    int largest=i;
    int l= 2*i+1;
    int r= 2*i+2;
    if(l<n && arr[l]>arr[largest])
    {
        largest=l;
    }
    if(r<n && arr[r]>arr[largest])
    {
        largest=r;
    }
    if(largest!=i)
    {
        swap(&arr[i],&arr[largest]);
        heapify(arr, n, largest);
    }
}
void heapsort(int arr[], int n)
{

    for (int i=n/2 - 1; i>=0;i--)
        heapify(arr,n,i);
    for (int i=n-1; i>=0; i--)
    {
        swap(&arr[0],&arr[i]);
        heapify(arr, i, 0);
    }
}
int main()
{
    int t,p;
    scanf("%d",&t);
    for(p=0;p<t;p++)
    {
        int n,i,j;
        scanf("%d",&n);
        int arr[n],b[n];
        for(i=0;i<n;i++)
        {
           scanf("%d",&arr[i]);
        }
        heapsort(arr,n);
        int m;
       if(n%2==0)
       {
           m=n/2;
       }
       else{m=(n+1)/2;}
       for(i=0,j=1;i<n,j<=m;i+=2,j++)
       {
           b[i]=arr[m-j];
       }
       for(i=1,j=0;i<n,j<=m;i+=2,j++)
       {
           b[i]=arr[m+j];
       }
       for(i=0;i<n;i++)
       {
           printf("%d ",b[i]);
       }
         printf("\n");
    }
}


#include<stdio.h>
void swap(int* a, int* b)
{
    int t= *a;
    *a = *b;
    *b = t;
}
int partition(int a[], int low, int high)
{
    int pivot=a[high];
    int i=low-1;
    for(int j=low;j<=high-1;j++)
    {
        if(a[j]<pivot)
        {
            i++;
            swap(&a[i],&a[j]);
        }
    }
    swap(&a[i+1],&a[high]);
    return i+1;
}
void quicksort(int a[], int low, int high)
{
   if(low<high)
   {
       int q=partition(a, low, high);
    quicksort(a, low, q-1);
    quicksort(a, q+1, high);
}
}
int main()
{
    int t,p;
    scanf("%d",&t);
    for(p=0;p<t;p++)
    {
        int n,i,j;
        scanf("%d",&n);
        int arr[n],b[n];
        for(i=0;i<n;i++)
        {
           scanf("%d",&arr[i]);
        }
        quicksort(arr, 0, n-1);
        int m;
       if(n%2==0)
       {
           m=n/2;
       }
       else{m=(n+1)/2;}
       for(i=0,j=1;i<n,j<=m;i+=2,j++)
       {
           b[i]=arr[m-j];
       }
       for(i=1,j=0;i<n,j<=m;i+=2,j++)
       {
           b[i]=arr[m+j];
       }
       for(i=0;i<n;i++)
       {
           printf("%d ",b[i]);
       }
         printf("\n");
    }
}


#include <stdio.h>

void swap(long int *xp,long int *yp)  ;

void main()
{
	long int t,n;
	scanf("%ld",&t);
	while(t--)
	{
		scanf("%ld",&n);
		long int arr[n];
		int i, j;

		for(i=0;i<n;i++)
			scanf("%ld",&arr[i]);
   		for (i = 0; i < n-1; i++)
       // Last i elements are already in place
       	for (j = 0; j < n-i-1; j++)
           	if (arr[j] > arr[j+1])
             	 swap(&arr[j], &arr[j+1]);

        if(n%2==0)
        {
        	for(i=(n/2)-1,j=(n/2);j<=n-1,i>=0;j++,i--)
        		printf("%ld %ld ",arr[i],arr[j]);
        }
        else
        {
        	printf("%ld ",arr[n/2] );
        	for(i=(n/2)-1,j=(n/2)+1;j<=n-1,i>=0;j++,i--)
        		printf("%ld %ld ",arr[i],arr[j]);
        }
        printf("\n");
    }
}

void swap(long int *xp,long int *yp)
{
    long int temp = *xp;
    *xp = *yp;
    *yp = temp;
}


#include <stdio.h>

void merge(long int arr[],long int l,long int m,long int r) ;
void mergeSort(long int arr[], long int l,long int r) ;

void main()
{
	long int t,n;
	scanf("%ld",&t);
	while(t--)
	{
		scanf("%ld",&n);
		long int arr[n];
		int i, j;

		for(i=0;i<n;i++)
			scanf("%ld",&arr[i]);

		mergeSort(arr, 0, n-1);

        if(n%2==0)
        {
        	for(i=(n/2)-1,j=(n/2);j<=n-1,i>=0;j++,i--)
        		printf("%ld %ld ",arr[i],arr[j]);
        }
        else
        {
        	printf("%ld ",arr[n/2] );
        	for(i=(n/2)-1,j=(n/2)+1;j<=n-1,i>=0;j++,i--)
        		printf("%ld %ld ",arr[i],arr[j]);
        }
        printf("\n");
    }
}

void merge(long int arr[],long int l,long int m,long int r)
{
    long int i, j, k;
    long int n1 = m - l + 1;
    long int n2 =  r - m;

    /* create temp arrays */
    long int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(long int arr[], long int l,long int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        long int m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}


#include<stdio.h>
#include<stdlib.h>

int cmp(const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}

int main()
{
	int n,m,i,j,k;
	scanf("%d", &n);
	while(n--)
	{
		scanf("%d", &m);
		int data[m];
		for(i=0; i<m; i++)
		 scanf("%d", data+i);
		qsort(data, m, sizeof(int), cmp);

		k = m/2;
		j = k;
		for(i=0; i<m; i++)
		{
			printf("%d ", data[j]);
			if(i%2==0)
				j = k-i/2-1;
			else
				j = k+i/2+1;
		}
		printf("\n");

	}
	return 0;

}


#include <stdio.h>
#include <stdlib.h>

int comparetor (const void * a, const void * b)
	{
		return ( *(int*)a - *(int*)b );
	}

int main(void)
{
 int t;
  scanf("%d",&t); int test;
   for(test=0;test<t;test++)
   {
   	int n;
   	scanf("%d",&n);
   	int a[n];
   	int i;
   	for(i=0;i<n;i++)
   	scanf("%d",a+i);
   	qsort(a,n,sizeof(int),comparetor); int m =n/2; int c=-1;

   	for(i=1;i<=n;i++)
   	{printf("%d ",a[m]);
   	 m+= (i)*c;
   	  c*=-1;
	   }

   	printf("\n");
   }
return 0;
}


#include <stdio.h>

void bubble(int *a, int n)
{int i; int j;
for(i=0;i<n;i++)
{ int min=i;
 for(j=i+1;j<n;j++)
{ if(a[j]<a[min])min=j;
} int t= a[min];
 a[min]= a[i];
  a[i]=t;
}

}

int main(void)
{
 int t;
  scanf("%d",&t); int test;
   for(test=0;test<t;test++)
   {
   	int n;
   	scanf("%d",&n);
   	int a[n];
   	int i;
   	for(i=0;i<n;i++)
   	scanf("%d",a+i);
   	bubble(a,n); int m =n/2; int c=-1;

   	for(i=1;i<=n;i++)
   	{printf("%d ",a[m]);
   	 m+= (i)*c;
   	  c*=-1;
	   }

   	printf("\n");
   }
return 0;
}


#include <stdio.h>
#include <stdlib.h>

static int compare(const void *a, const void *b)
{
	return (*(long long int*)(a) < *(long long int*)(b));
}

int main()
{
	unsigned int n_test_cases;
	scanf("%u", &n_test_cases);

	while(n_test_cases--)
	{
		unsigned long n_numbers;
		scanf("%lu", &n_numbers);

		long long int numbers[n_numbers];
		unsigned long i;
		for(i = 0; i < n_numbers; i++)
			scanf("%lld", &numbers[i]);

		qsort(numbers, n_numbers, sizeof(long long int), compare);

		unsigned long j = 0;
		long long int ordered[n_numbers];
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 2 - i] = numbers[j++];
		j = n_numbers - 1;
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 1 - i] = numbers[j--];
		for(i = 0; i < n_numbers; i++)
			if(i == n_numbers - 1)
				printf("%lld\n", ordered[i]);
			else
				printf("%lld ", ordered[i]);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

/*static int compare(const void *a, const void *b)
{
	return (*(long long int*)(a) < *(long long int*)(b));
}*/

int compare(const void *a,const void *b)
{
	if(*(int *)a>*(int *)b)
		return 1;
	if(*(int *)a==*(int *)b)
		return 0;
	return -1;
}

long long int partition(long long int arr[], long long int lo, long long int hi)
{
	long long int pivot = arr[hi];
	long long int i = lo, j;
	for(j = lo; j < hi; j++)
	{
		if(arr[j] > pivot)
		{
			long long int t = arr[j];
			arr[j] = arr[i];
			arr[i] = t;
			i++;
		}
	}
	long long int t = arr[j];
	arr[j] = arr[i];
	arr[i] = t;
	return i;
}

void _qsort(long long int arr[], long long int lo, long long int hi)
{
	if(lo < hi)
	{
		long long int p = partition(arr, lo, hi);
		_qsort(arr, lo, p - 1);
		_qsort(arr, p + 1, hi);
	}
}

void sort(long long int arr[], long long int size)
{
	long i, j;
	for(i = 0; i < size - 1; i++)
	{
		for(j = i + 1; j < size; j++)
		{
			if(arr[i] < arr[j])
			{
				long long int t = arr[i];
				arr[i] = arr[j];
				arr[j] = t;
			}
		}
	}
}

void print(long long int arr[], long long int size)
{
	long long int i;
	for(i = 0; i < size; i++)
		if(i == size - 1)
			printf("%lld\n", arr[i]);
		else
			printf("%lld ", arr[i]);
}

bool issorted(long long int arr[], long long int size)
{
	long long int i;
	for(i = 0; i < size - 1; i++)
		if(arr[i] < arr[i + 1])
			return 0;
	return 1;
}

int main()
{
	int n_test_cases;
	scanf("%d", &n_test_cases);

	while(n_test_cases--)
	{
		long n_numbers;
		scanf("%ld", &n_numbers);

		long long int numbers[n_numbers];
		long i;
		for(i = 0; i < n_numbers; i++)
			scanf("%lld", &numbers[i]);

		//qsort(numbers, n_numbers, sizeof(long long int), compare);
		if(!issorted(numbers, n_numbers))
			_qsort(numbers, 0, n_numbers - 1);

		long j = 0;
		long long int ordered[n_numbers];
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 2 - i] = numbers[j++];
		j = n_numbers - 1;
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 1 - i] = numbers[j--];
		for(i = 0; i < n_numbers; i++)
			if(i == n_numbers - 1)
				printf("%lld\n", ordered[i]);
			else
				printf("%lld ", ordered[i]);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

/*static int compare(const void *a, const void *b)
{
	return (*(long long int*)(a) < *(long long int*)(b));
}*/

void sort(long long int arr[], long long int size)
{
	long i, j;
	for(i = 0; i < size - 1; i++)
	{
		for(j = i + 1; j < size; j++)
		{
			if(arr[i] < arr[j])
			{
				long long int t = arr[i];
				arr[i] = arr[j];
				arr[j] = t;
			}
		}
	}
}

int main()
{
	int n_test_cases;
	scanf("%d", &n_test_cases);

	while(n_test_cases--)
	{
		long n_numbers;
		scanf("%ld", &n_numbers);

		long long int numbers[n_numbers];
		long i;
		for(i = 0; i < n_numbers; i++)
			scanf("%lld", &numbers[i]);

		//qsort(numbers, n_numbers, sizeof(long long int), compare);
		sort(numbers, n_numbers);

		long j = 0;
		long long int ordered[n_numbers];
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 2 - i] = numbers[j++];
		j = n_numbers - 1;
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 1 - i] = numbers[j--];
		for(i = 0; i < n_numbers; i++)
			if(i == n_numbers - 1)
				printf("%lld\n", ordered[i]);
			else
				printf("%lld ", ordered[i]);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

/*static int compare(const void *a, const void *b)
{
	return (*(long long int*)(a) < *(long long int*)(b));
}*/

long long int partition(long long int arr[], long long int lo, long long int hi)
{
	long long int pivot = arr[hi];
	long long int i = lo, j;
	for(j = lo; j < hi; j++)
	{
		if(arr[j] > pivot)
		{
			long long int t = arr[j];
			arr[j] = arr[i];
			arr[i] = t;
			i++;
		}
	}
	long long int t = arr[j];
	arr[j] = arr[i];
	arr[i] = t;
	return i;
}

void _qsort(long long int arr[], long long int lo, long long int hi)
{
	if(lo < hi)
	{
		long long int p = partition(arr, lo, hi);
		_qsort(arr, lo, p - 1);
		_qsort(arr, p + 1, hi);
	}
}

void sort(long long int arr[], long long int size)
{
	long i, j;
	for(i = 0; i < size - 1; i++)
	{
		for(j = i + 1; j < size; j++)
		{
			if(arr[i] < arr[j])
			{
				long long int t = arr[i];
				arr[i] = arr[j];
				arr[j] = t;
			}
		}
	}
}

void print(long long int arr[], long long int size)
{
	long long int i;
	for(i = 0; i < size; i++)
		if(i == size - 1)
			printf("%lld\n", arr[i]);
		else
			printf("%lld ", arr[i]);
}

int main()
{
	int n_test_cases;
	scanf("%d", &n_test_cases);

	while(n_test_cases--)
	{
		long n_numbers;
		scanf("%ld", &n_numbers);

		long long int numbers[n_numbers];
		long i;
		for(i = 0; i < n_numbers; i++)
			scanf("%lld", &numbers[i]);

		//qsort(numbers, n_numbers, sizeof(long long int), compare);
		//sort(numbers, n_numbers);
		//print(numbers, n_numbers);
		_qsort(numbers, 0, n_numbers - 1);
		//print(numbers, n_numbers);

		long j = 0;
		long long int ordered[n_numbers];
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 2 - i] = numbers[j++];
		j = n_numbers - 1;
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 1 - i] = numbers[j--];
		for(i = 0; i < n_numbers; i++)
			if(i == n_numbers - 1)
				printf("%lld\n", ordered[i]);
			else
				printf("%lld ", ordered[i]);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

/*static int compare(const void *a, const void *b)
{
	return (*(long long int*)(a) < *(long long int*)(b));
}*/

int compare(const void *a,const void *b)
{
	if(*(int *)a>*(int *)b)
		return 1;
	if(*(int *)a==*(int *)b)
		return 0;
	return -1;
}

long long int partition(long long int arr[], long long int lo, long long int hi)
{
	long long int pivot = arr[hi];
	long long int i = lo, j;
	for(j = lo; j < hi; j++)
	{
		if(arr[j] > pivot)
		{
			long long int t = arr[j];
			arr[j] = arr[i];
			arr[i] = t;
			i++;
		}
	}
	long long int t = arr[j];
	arr[j] = arr[i];
	arr[i] = t;
	return i;
}

void _qsort(long long int arr[], long long int lo, long long int hi)
{
	if(lo < hi)
	{
		long long int p = partition(arr, lo, hi);
		_qsort(arr, lo, p - 1);
		_qsort(arr, p + 1, hi);
	}
}

void sort(long long int arr[], long long int size)
{
	long i, j;
	for(i = 0; i < size - 1; i++)
	{
		for(j = i + 1; j < size; j++)
		{
			if(arr[i] < arr[j])
			{
				long long int t = arr[i];
				arr[i] = arr[j];
				arr[j] = t;
			}
		}
	}
}

void print(long long int arr[], long long int size)
{
	long long int i;
	for(i = 0; i < size; i++)
		if(i == size - 1)
			printf("%lld\n", arr[i]);
		else
			printf("%lld ", arr[i]);
}

int main()
{
	int n_test_cases;
	scanf("%d", &n_test_cases);

	while(n_test_cases--)
	{
		long n_numbers;
		scanf("%ld", &n_numbers);

		long long int numbers[n_numbers];
		long i;
		for(i = 0; i < n_numbers; i++)
			scanf("%lld", &numbers[i]);

		qsort(numbers, n_numbers, sizeof(long long int), compare);
		//sort(numbers, n_numbers);
		//print(numbers, n_numbers);
		//_qsort(numbers, 0, n_numbers - 1);
		//print(numbers, n_numbers);

		long j = 0;
		long long int ordered[n_numbers];
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 2 - i] = numbers[j++];
		j = n_numbers - 1;
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 1 - i] = numbers[j--];
		for(i = 0; i < n_numbers; i++)
			if(i == n_numbers - 1)
				printf("%lld\n", ordered[i]);
			else
				printf("%lld ", ordered[i]);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

static int compare(const void *a, const void *b)
{
	return (*(long long int*)(a) < *(long long int*)(b));
}

int main()
{
	unsigned int n_test_cases;
	scanf("%u", &n_test_cases);

	while(n_test_cases--)
	{
		long n_numbers;
		scanf("%ld", &n_numbers);

		long long int numbers[n_numbers];
		long i;
		for(i = 0; i < n_numbers; i++)
			scanf("%lld", &numbers[i]);

		qsort(numbers, n_numbers, sizeof(long long int), compare);

		long j = 0;
		long long int ordered[n_numbers];
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 2 - i] = numbers[j++];
		j = n_numbers - 1;
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 1 - i] = numbers[j--];
		for(i = 0; i < n_numbers; i++)
			if(i == n_numbers - 1)
				printf("%lld\n", ordered[i]);
			else
				printf("%lld ", ordered[i]);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

static int compare(const void *a, const void *b)
{
	return (*(signed long int*)(a) < *(signed long int*)(b));
}

int main()
{
	unsigned int n_test_cases;
	scanf("%u", &n_test_cases);

	while(n_test_cases--)
	{
		unsigned long n_numbers;
		scanf("%lu", &n_numbers);

		long long int numbers[n_numbers];
		unsigned long i;
		for(i = 0; i < n_numbers; i++)
			scanf("%lld", &numbers[i]);

		qsort(numbers, n_numbers, sizeof(long long int), compare);

		unsigned long j = 0;
		long long int ordered[n_numbers];
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 2 - i] = numbers[j++];
		j = n_numbers - 1;
		for(i = 0; i < n_numbers; i += 2)
			ordered[n_numbers - 1 - i] = numbers[j--];
		for(i = 0; i < n_numbers; i++)
			if(i == n_numbers - 1)
				printf("%lld\n", ordered[i]);
			else
				printf("%lld ", ordered[i]);
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void shuffle(long long *array, size_t n)
{
    if (n > 1)
    {
        size_t i;
        for (i = 0; i < n - 1; i++)
        {
          size_t j = i + rand() / (RAND_MAX / (n - i) + 1);
          int t = array[j];
          array[j] = array[i];
          array[i] = t;
        }
    }
}

int compare_ints(const void *p, const void *q) {
    int x = *(const int *)p;
    int y = *(const int *)q;

    /* Avoid return x - y, which can cause undefined behaviour
       because of signed integer overflow. */
    if (x < y)
        return 1;  // Return -1 if you want ascending, 1 if you want descending order.
    else if (x > y)
        return -1;   // Return 1 if you want ascending, -1 if you want descending order.

    return 0;
}

int main (void){
	long long T, i, j, n, a[100000], b[100000];
	scanf( "%lld", &T );
	for( i = 0; i < T; i++ ){
		scanf( "%lld", &n );
		for( j = 0; j < n; j++ ){
			scanf( "%lld", &a[j] );
		}
		shuffle( a, n);
		qsort(a, n, sizeof(long long), compare_ints);
		for( j = 0; j < n; j++ ){
			if( j%2 == 0 )
				b[j] = a[j/2];
			else
				b[j] = a[n-1-j/2];
		}
		for( j = n-1; j >=0; j-- )
			printf( "%lld ", b[j] );
		printf("\n");
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void shuffle(long long *array, size_t n) {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    int usec = tv.tv_usec;
    srand48(usec);

    if (n > 1) {
        size_t i;
        for (i = n - 1; i > 0; i--) {
            size_t j = (unsigned int) (drand48()*(i+1));
            int t = array[j];
            array[j] = array[i];
            array[i] = t;
        }
    }
}

int compare_ints(const void *p, const void *q) {
    int x = *(const int *)p;
    int y = *(const int *)q;

    /* Avoid return x - y, which can cause undefined behaviour
       because of signed integer overflow. */
    if (x < y)
        return 1;  // Return -1 if you want ascending, 1 if you want descending order.
    else if (x > y)
        return -1;   // Return 1 if you want ascending, -1 if you want descending order.

    return 0;
}

int main (void){
	long long T, i, j, n, a[100000], b[100000];
	scanf( "%lld", &T );
	for( i = 0; i < T; i++ ){
		scanf( "%lld", &n );
		for( j = 0; j < n; j++ ){
			scanf( "%lld", &a[j] );
		}
		shuffle( a, n);
		qsort(a, n, sizeof(long long), compare_ints);
		for( j = 0; j < n; j++ ){
			if( j%2 == 0 )
				b[j] = a[j/2];
			else
				b[j] = a[n-1-j/2];
		}
		for( j = n-1; j >=0; j-- )
			printf( "%lld ", b[j] );
		printf("\n");
	}
	return 0;
}


#define _XOPEN_SOURCE    /* ALWAYS BEFORE the include statement */

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

void shuffle(long long *array, size_t n) {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    int usec = tv.tv_usec;
    srand48(usec);

    if (n > 1) {
        size_t i;
        for (i = n - 1; i > 0; i--) {
            size_t j = (unsigned int) (drand48()*(i+1));
            int t = array[j];
            array[j] = array[i];
            array[i] = t;
        }
    }
}

int compare_ints(const void *p, const void *q) {
    int x = *(const int *)p;
    int y = *(const int *)q;

    /* Avoid return x - y, which can cause undefined behaviour
       because of signed integer overflow. */
    if (x < y)
        return 1;  // Return -1 if you want ascending, 1 if you want descending order.
    else if (x > y)
        return -1;   // Return 1 if you want ascending, -1 if you want descending order.

    return 0;
}

int main (void){
	long long T, i, j, n, a[100000], b[100000];
	scanf( "%lld", &T );
	for( i = 0; i < T; i++ ){
		scanf( "%lld", &n );
		for( j = 0; j < n; j++ ){
			scanf( "%lld", &a[j] );
		}
		shuffle( a, n);
		qsort(a, n, sizeof(long long), compare_ints);
		for( j = 0; j < n; j++ ){
			if( j%2 == 0 )
				b[j] = a[j/2];
			else
				b[j] = a[n-1-j/2];
		}
		for( j = n-1; j >=0; j-- )
			printf( "%lld ", b[j] );
		printf("\n");
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

void shuffle(long long *array, size_t n) {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    int usec = tv.tv_usec;
    srand48(usec);

    if (n > 1) {
        size_t i;
        for (i = n - 1; i > 0; i--) {
            size_t j = (unsigned int) (drand48()*(i+1));
            int t = array[j];
            array[j] = array[i];
            array[i] = t;
        }
    }
}

int compare_ints(const void *p, const void *q) {
    int x = *(const int *)p;
    int y = *(const int *)q;

    /* Avoid return x - y, which can cause undefined behaviour
       because of signed integer overflow. */
    if (x < y)
        return 1;  // Return -1 if you want ascending, 1 if you want descending order.
    else if (x > y)
        return -1;   // Return 1 if you want ascending, -1 if you want descending order.

    return 0;
}

int main (void){
	long long T, i, j, n, a[100000], b[100000];
	scanf( "%lld", &T );
	for( i = 0; i < T; i++ ){
		scanf( "%lld", &n );
		for( j = 0; j < n; j++ ){
			scanf( "%lld", &a[j] );
		}
		shuffle( a, n);
		qsort(a, n, sizeof(long long), compare_ints);
		for( j = 0; j < n; j++ ){
			if( j%2 == 0 )
				b[j] = a[j/2];
			else
				b[j] = a[n-1-j/2];
		}
		for( j = n-1; j >=0; j-- )
			printf( "%lld ", b[j] );
		printf("\n");
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>
#define e 1000000007

typedef  long long ll;

int int_cmp(const void *a, const void *b){
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib;
}

ll int_cmp1(const void *a, const void *b){
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib;
}

int max(int a,int b){
	if(a<b)
		a=b;
	return a;
}

int min(int a,int b){
	if(a>b)
		a=b;
	return a;
}

int absolu(int n){
	if(n<0)
		n*=-1;

	return n;
}

void solve(){
 ll a[100000],b[100000];
 int len=0,n,i,j;

 scanf("%d",&n);
 for(i=0 ; i<n ; i++)
 	scanf("%lld",&a[i]);

 qsort(a,n,sizeof(ll),int_cmp1);

 int l=0,r=n-1;
 while(l<=r){
 	b[len++]=a[l];
 	b[len++]=a[r];
 	l++;
 	r--;
 }
 for(i=0 ; i<len ;i++)
 	printf("%lld ",b[i]);

}

int main(){
  int t;
	scanf("%d",&t);

	while(t--)
		solve();

	return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>
#define e 1000000007

typedef  long long ll;

int int_cmp(const void *a, const void *b){
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib;
}

ll int_cmp1(const void *a, const void *b){
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib;
}

int max(int a,int b){
	if(a<b)
		a=b;
	return a;
}

int min(int a,int b){
	if(a>b)
		a=b;
	return a;
}

int absolu(int n){
	if(n<0)
		n*=-1;

	return n;
}

void solve(){
 ll a[100000],b[100000];
 int len=0,n,i,j;

 scanf("%d",&n);
 for(i=0 ; i<n ; i++)
 	scanf("%lld\n",&a[i]);

 qsort(a,n,sizeof(ll),int_cmp1);

 int l=0,r=n-1;
 while(l<=r){
 	b[len++]=a[l];
 	b[len++]=a[r];
 	l++;
 	r--;
 }
 for(i=n-1 ; i>=0 ;i--)
 	printf("%lld ",b[i]);
	printf("\n");
}

int main(){
  int t;
	scanf("%d",&t);

	while(t--)
		solve();

	return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>
#define e 1000000007

typedef  long long ll;

int int_cmp(const void *a, const void *b){
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib;
}

ll int_cmp1(const void *a, const void *b){
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib;
}

int max(int a,int b){
	if(a<b)
		a=b;
	return a;
}

int min(int a,int b){
	if(a>b)
		a=b;
	return a;
}

int absolu(int n){
	if(n<0)
		n*=-1;

	return n;
}

void solve(){
 ll a[100000];
 int n,i,j;

 scanf("%d",&n);
 for(i=0 ; i<n ; i++)
 	scanf("%lld\n",&a[i]);

 qsort(a,n,sizeof(ll),int_cmp1);

 for(i=0 ; i<n ; i++){
 	if(a[i]<0)
 	{   ll tmp=a[i];
		for(j=i ; j<n-1 ; j++){
			a[j]=a[j+1];
		}
		a[n-1]=tmp;
	}
 }

 for(i=0 ; i<n ; i++){
 	for(j=0 ; j<n-3 ; j+=2){
 		if(abs(a[j]-a[j+1])>abs(a[j+2]-a[j+3])){
 			ll tmp1,tmp2;
 			tmp1=a[j];
 			a[j]=a[j+2];
 			a[j+2]=tmp1;
 			tmp2= a[j+1];
 			a[j+1]=a[j+3];
 			a[j+3]=tmp2;
		 }
	 }
 }

 for(i=0 ; i<n ;i++)
 	printf("%lld ",a[i]);
 	printf("\n");
}

int main(){
  int t;
	scanf("%d",&t);

	while(t--)
		solve();

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
/*#define LOCAL*/
#define maxn 1000000
long long array[maxn];

int comparator(const void *p, const void *q) {
        long long this = *(const long long *)p;
        long long that = *(const long long *)q;
        if(this < that) return -1;
        else if(this == that) return 0;
        else return 1;
}

void swap(long long *arr, int i, int j) {
        long long temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
}

void shuffle(long long *arr, int n) {
       int i, j;
       for(i = 0; i < n; i++) {
               j = rand() % (i + 1);
               swap(arr, i, j);
       }
}

void print_array(long long *arr, int len) {
        int i;
        for(i = 0; i < len; i++) {
                if(!i) printf("%lld", arr[i]);
                else printf(" %lld", arr[i]);
        }
        putchar('\n');
}

int main() {

#ifdef LOCAL
        freopen("data.in", "r", stdin);
        freopen("data.out", "w", stdout);
#endif
        int t;
        int n, counter = 0;
        scanf("%d", &t);
        while(t--) {
                counter = 0;
                scanf("%d", &n);
                while(n--) {
                        scanf("%lld", &array[counter++]);
                }

                shuffle(array, counter);
                qsort(array, counter, sizeof(long long), comparator);
                int mid = counter / 2;
                printf("%lld", array[mid]);
                int i = mid + 1;
                int j = mid - 1;
                int sign = 1;
                int k;
                for(k = 1; k < counter; k++) {
                        if(sign) printf(" %lld", array[j--]);
                        else printf(" %lld", array[i++]);
                        sign = 1 - sign;
                }
                putchar('\n');
        }
        return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
/*#define LOCAL*/
#define maxn 1000000
long long array[maxn];

int comparator(const void *p, const void *q) {
        long long this = *(const long long *)p;
        long long that = *(const long long *)q;
        if(this < that) return -1;
        else if(this == that) return 0;
        else return 1;
}

void swap(long long *arr, int i, int j) {
        long long temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
}

void shuffle(long long *arr, int n) {
       int i, j;
       for(i = 0; i < n; i++) {
               j = rand() % (i + 1);
               swap(arr, i, j);
       }
}

void print_array(long long *arr, int len) {
        int i;
        for(i = 0; i < len; i++) {
                if(!i) printf("%lld", arr[i]);
                else printf(" %lld", arr[i]);
        }
        putchar('\n');
}

int main() {

#ifdef LOCAL
        freopen("data.in", "r", stdin);
        freopen("data.out", "w", stdout);
#endif
        int t;
        int n, counter = 0;
        scanf("%d", &t);
        while(t--) {
                counter = 0;
                scanf("%d", &n);
                while(n--) {
                        scanf("%lld", &array[counter++]);
                }

                shuffle(array, counter);
                qsort(array, counter, sizeof(long long), comparator);
                int mid = (counter + 1) / 2;
                printf("%lld", array[mid]);
                int i = mid + 1;
                int j = mid - 1;
                int sign = 1;
                int k;
                for(k = 1; k < counter; k++) {
                        if(sign) printf(" %lld", array[j--]);
                        else printf(" %lld", array[i++]);
                        sign = 1 - sign;
                }
                putchar('\n');
        }
        return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int comp(const void*a,const void*b)
{
	return *(int*)a-*(int*)b;
}
int a[1000005];
int main()
{
	int n,i,t,m;
	scanf("%d",&t);
	while(t--)
	{
		int p=0,q=1;
        scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		qsort(a,n,sizeof(a[0]),comp);
        if(n%2==1)
		{
			printf("%d ",a[n/2]);
		}
		for(i=n/2-1;i>=0;i--)
		{
			printf("%d %d ",a[n-i-1],a[i]);
		}
		printf("\n");
    }

	//system("pause");
	return 0;
 }


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void merge(int a[],int l,int r,int mid)
{
  int aux[r-l+1],i,j,k;

  for(k=l;k<=r;k++)
  aux[k-l]=a[k];
  i=l;
  j=mid+1;
  for(k=l;k<=r;k++)
  {
  	if(i>mid)
  	{
  		a[k]=aux[j-l];
  		j++;
	  }
	else if(j>r)
	{
		a[k]=aux[i-l];
		i++;
	  }
	else if(aux[i-l]>aux[j-l])
	{
		a[k]=aux[j-l];
		j++;
		}
	else
	{
		a[k]=aux[i-l];
		i++;
			}
	  }

}

void merge_sort(int a[],int l,int r)
{
    if(l>=r)
	return ;
	int mid=(l+r)/2;
	merge_sort(a,l,mid);
	merge_sort(a,mid+1,r);
	merge(a,l,r,mid);

}

void mergesort(int a[],int l,int r)
{
	merge_sort(a,l,r-1);
}
int a[1000005],str[1000005];
int main()
{
	int n,i,t,m;
	scanf("%d",&t);
	while(t--)
	{
		int p=0,q=1;
		memset(str,0,sizeof(str));
        scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		mergesort(a,0,n);
        int l=0,r=n-1;
        if(n%2==1)
        {
            for(i=0;i<n/2;i++)
            {
                str[l++]=a[i];
				str[l++]=a[n-1-i];
				//printf("%d %d ",a[i],a[n-1-i]);
            }
			//printf("\n");
	    }
        else
        {
            for(i=0;i<n/2;i++)
            {
                str[l++]=a[i];
				str[l++]=a[n-1-i];
				//printf("%d %d",a[i],a[n-1-i]);
            }
			str[l++]=a[n/2];
            //printf("%d/n",a[n/2+1]);
        }
		for(i=l-2;i>=0;i--)
		{
			printf("%d ",str[i]);
		}
		printf("\n");
    }

	//system("pause");
	return 0;
 }


#include<stdio.h>
#include<stdlib.h>

void merge(int a[],int l,int r,int mid)
{
  int aux[r-l+1],i,j,k;

  for(k=l;k<=r;k++)
  aux[k-l]=a[k];
  i=l;
  j=mid+1;
  for(k=l;k<=r;k++)
  {
  	if(i>mid)
  	{
  		a[k]=aux[j-l];
  		j++;
	  }
	else if(j>r)
	{
		a[k]=aux[i-l];
		i++;
	  }
	else if(aux[i-l]>aux[j-l])
	{
		a[k]=aux[j-l];
		j++;
		}
	else
	{
		a[k]=aux[i-l];
		i++;
			}
	  }

}

void merge_sort(int a[],int l,int r)
{
    if(l>=r)
	return ;
	int mid=(l+r)/2;
	merge_sort(a,l,mid);
	merge_sort(a,mid+1,r);
	merge(a,l,r,mid);

}

void mergesort(int a[],int l,int r)
{
	merge_sort(a,l,r-1);
}
int a[1000005];
int main()
{
	int n,i,t,m;
	scanf("%d",&t);
	while(t--)
	{
		int min,p=0,q=1;
        scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		mergesort(a,0,n);
        min=a[1]-a[0];
		for(i=1;i<n;i++)
		{
			//printf("%d\n",a[i]);
            if(a[i]-a[i-1]<min)
            {
                min=a[i]-a[i-1];
                p=i-1;
                q=i;
            }
		}
        while(p>=0&&q<n)
        {
            printf("%d ",a[p--]);
            printf("%d ",a[q++]);
        }
        while(p>=0)
        {
            printf("%d ",a[p--]);
        }
        while(q<n)
        {
            printf("%d ",a[q++]);
        }
        printf("\n");

	}

	//system("pause");
	return 0;
 }


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void merge(int a[],int l,int r,int mid)
{
  int aux[r-l+1],i,j,k;

  for(k=l;k<=r;k++)
  aux[k-l]=a[k];
  i=l;
  j=mid+1;
  for(k=l;k<=r;k++)
  {
  	if(i>mid)
  	{
  		a[k]=aux[j-l];
  		j++;
	  }
	else if(j>r)
	{
		a[k]=aux[i-l];
		i++;
	  }
	else if(aux[i-l]>aux[j-l])
	{
		a[k]=aux[j-l];
		j++;
		}
	else
	{
		a[k]=aux[i-l];
		i++;
			}
	  }

}

void merge_sort(int a[],int l,int r)
{
    if(l>=r)
	return ;
	int mid=(l+r)/2;
	merge_sort(a,l,mid);
	merge_sort(a,mid+1,r);
	merge(a,l,r,mid);

}

void mergesort(int a[],int l,int r)
{
	merge_sort(a,l,r-1);
}
int a[1000005],str[1000005];
int main()
{
	int n,i,t,m;
	scanf("%d",&t);
	while(t--)
	{
		int p=0,q=1;
		memset(str,0,sizeof(str));
        scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		mergesort(a,0,n);
        if(n%2==1)
		{
			printf("%d ",a[n/2]);
		}
		for(i=n/2-1;i>=0;i--)
		{
			printf("%d %d ",a[n-i-1],a[i]);
		}
		printf("\n");
    }

	//system("pause");
	return 0;
 }


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void merge(int a[],int l,int r,int mid)
{
  int aux[r-l+1],i,j,k;

  for(k=l;k<=r;k++)
  aux[k-l]=a[k];
  i=l;
  j=mid+1;
  for(k=l;k<=r;k++)
  {
  	if(i>mid)
  	{
  		a[k]=aux[j-l];
  		j++;
	  }
	else if(j>r)
	{
		a[k]=aux[i-l];
		i++;
	  }
	else if(aux[i-l]>aux[j-l])
	{
		a[k]=aux[j-l];
		j++;
		}
	else
	{
		a[k]=aux[i-l];
		i++;
			}
	  }

}

void merge_sort(int a[],int l,int r)
{
    if(l>=r)
	return ;
	int mid=(l+r)/2;
	merge_sort(a,l,mid);
	merge_sort(a,mid+1,r);
	merge(a,l,r,mid);

}

void mergesort(int a[],int l,int r)
{
	merge_sort(a,l,r-1);
}
int a[1000005],str[1000005];
int main()
{
	int n,i,t,m;
	scanf("%d",&t);
	while(t--)
	{
		int p=0,q=1;
		memset(str,0,sizeof(str));
        scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		mergesort(a,0,n);
        int l=0,r=n-1;
        if(n%2==0)
        {
            for(i=0;i<n/2;i++)
            {
                str[l++]=a[i];
				str[l++]=a[n-1-i];
				//printf("%d %d ",a[i],a[n-1-i]);
            }
			//printf("\n");
	    }
        else
        {
            for(i=0;i<n/2;i++)
            {
                str[l++]=a[i];
				str[l++]=a[n-1-i];
				//printf("%d %d",a[i],a[n-1-i]);
            }
			str[l++]=a[n/2+1];
            //printf("%d/n",a[n/2+1]);
        }
		for(i=l-1;i>=0;i--)
		{
			printf("%d ",str[i]);
		}
		printf("\n");
    }

	//system("pause");
	return 0;
 }


#include<stdio.h>
#include<stdlib.h>

void merge(int a[],int l,int r,int mid)
{
  int aux[r-l+1],i,j,k;

  for(k=l;k<=r;k++)
  aux[k-l]=a[k];
  i=l;
  j=mid+1;
  for(k=l;k<=r;k++)
  {
  	if(i>mid)
  	{
  		a[k]=aux[j-l];
  		j++;
	  }
	else if(j>r)
	{
		a[k]=aux[i-l];
		i++;
	  }
	else if(aux[i-l]>aux[j-l])
	{
		a[k]=aux[j-l];
		j++;
		}
	else
	{
		a[k]=aux[i-l];
		i++;
			}
	  }

}

void merge_sort(int a[],int l,int r)
{
    if(l>=r)
	return ;
	int mid=(l+r)/2;
	merge_sort(a,l,mid);
	merge_sort(a,mid+1,r);
	merge(a,l,r,mid);

}

void mergesort(int a[],int l,int r)
{
	merge_sort(a,l,r-1);
}
int a[1000005];
int main()
{
	int n,i,t,m;
	scanf("%d",&t);
	while(t--)
	{
		int p=0,q=1;
        long long min;
        scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%d",&a[i]);
		}
		mergesort(a,0,n);
        min=a[1]-a[0];
		for(i=1;i<n;i++)
		{
            if(a[i]-a[i-1]<min)
            {
                min=a[i]-a[i-1];
                p=i-1;
            }
		}
        //printf("%d\n",p);
        printf("%d ",a[p]);

        int r,l;
        r=p+1;
        l=p-1;
        while(l>=0&&r<n)
        {

            if(a[r]-a[p]<a[p]-a[l])
            {
                printf("%d ",a[r]);
                p=r;
                r++;

            }
            else
            {
                printf("%d ",a[l]);
                p=l;
                l--;
            }
        }
        while(l>=0)
        {
            printf("%d ",a[l--]);
        }
        while(r<n)
        {
            printf("%d ",a[r++]);
        }
        printf("\n");

	}

	//system("pause");
	return 0;
 }


#include<stdio.h>
#include<stdlib.h>
void mergeSort(int arr[], int l, int r);
void merge(int arr[], int l, int m, int r);

#define M 100001
int main(){
    int i,j,T,n,k;
    int arr[M],diff[M-1];
    scanf("%d",&T);
    for(i=0; i<T; i++){
		scanf("%d",&n);

		for(j=0; j<n; j++){
			scanf("%d",&arr[j]);
		}
		mergeSort(arr, 0, n-1);
		if(n%2==0) {j=n/2-1; k=n/2;}
		else{j=n/2; k=n/2+1;}
		for(; j>=0||k<n;){
			if(j>=0) {printf("%d ", arr[j]); j--;}
			if(k<n) {printf("%d ",arr[k]); k++;}
		}
	}
    return 0;
}

void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}

void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define ll long long
ll int cmp(void* a, void* b)
{
    return *((ll int*)a) - *((ll int*)b);
}
int main()
{
    ll int n, f, d, i, j, g;
    scanf("%lld", &n);
    while(n--)
    {
        scanf("%lld", &f);
        d = f;
        g = 1;
        ll int array[f];
        ll int fin[f];
        for(i = 0; i < f; i++) scanf("%lld", &array[i]);
        qsort(array, f, sizeof(ll int), cmp);
        i = 0;
        j = f - 1;
        fin[--d] = array[i];
        fin[--d] = array[j];
        i++; j--;
        while(j >= i)
        {
            //if(array[j] < 0 )//array[j] - array[i] > array[i] - array[j])
            //{
            if(g)
            {
                fin[--d] = array[i];
                fin[--d] = array[j];
                //g = 0;
            }
            //else
            /*{
                g = 1;
                fin[--d] = array[i];
                fin[--d] = array[j];
           // *///
           /* else
            {
                fin[--d] = array[j];
                fin[--d] = array[i];
           // }*/
            j--;
            i++;
        }
        printf("%lld", fin[0]);
        for(ll int i = 1; i < f; i++) printf(" %lld", fin[i]);
        printf("\n");
    }
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define ll long long
ll int cmp(void* a, void* b)
{
    return *((ll int*)a) - *((ll int*)b);
}
int main()
{
    ll int n, f, d, i, j;
    scanf("%lld", &n);
    while(n--)
    {
        scanf("%lld", &f);
        d = f;
        ll int array[f];
        ll int fin[f];
        for(i = 0; i < f; i++) scanf("%lld", &array[i]);
        qsort(array, f, sizeof(ll int), cmp);
        i = 0;
        j = f - 1;
        fin[--d] = array[i];
        fin[--d] = array[j];
        i++; j--;
        while(j > i)
        {
            //if(array[j] < 0 )//array[j] - array[i] > array[i] - array[j])
            //{
                fin[--d] = array[j];
                fin[--d] = array[i];
            //}
           /* else
            {
                fin[--d] = array[j];
                fin[--d] = array[i];
           // }*/
            j--;
            i++;
        }
        printf("%lld", fin[0]);
        for(ll int i = 1; i < f; i++) printf(" %lld", fin[i]);
        printf("\n");
    }
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int cmp(void* a, void* b)
{
    return *((int*)a) - *((int*)b);
}
int main()
{
    int n, f, d, i, j;
    scanf("%d", &n);
    while(n--)
    {
        scanf("%d", &f);
        d = f;
        int array[f];
        int fin[f];
        for(i = 0; i < f; i++) scanf("%d", &array[i]);
        qsort(array, f, 4, cmp);
        i = 0;
        j = f - 1;
        fin[--d] = array[i];
        fin[--d] = array[j];
        i++; j--;
        while(j > i)
        {
            //if(array[j] < 0 )//array[j] - array[i] > array[i] - array[j])
            //{
                fin[--d] = array[j];
                fin[--d] = array[i];
            //}
           /* else
            {
                fin[--d] = array[j];
                fin[--d] = array[i];
           // }*/
            j--;
            i++;
        }
        printf("%d", fin[0]);
        for(int i = 1; i < f; i++) printf(" %d", fin[i]);
        printf("\n");
    }
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define ll long long
ll int cmp(void* a, void* b)
{
    return *((ll int*)a) - *((ll int*)b);
}
int main()
{
    ll int n, f, d, i, j, g;
    scanf("%lld", &n);
    while(n--)
    {
        scanf("%lld", &f);
        d = f;
        g = 1;
        ll int array[f];
        ll int fin[f];
        for(i = 0; i < f; i++) scanf("%lld", &array[i]);
        qsort(array, f, sizeof(ll int), cmp);
        i = 0;
        j = f - 1;
        fin[--d] = array[i];
        fin[--d] = array[j];
        i++; j--;
        while(j >= i)
        {
            fin[--d] = array[i++];
            fin[--d] = array[j--];
        }
        printf("%lld", fin[0]);
        for(ll int i = 1; i < f; i++) printf(" %lld", fin[i]);
        printf("\n");
    }
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define ll long long
ll int cmp(void* a, void* b)
{
    return *((ll int*)a) - *((ll int*)b);
}
int main()
{
    ll int n, f, d, i, j;
    scanf("%lld", &n);
    while(n--)
    {
        scanf("%d", &f);
        d = f;
        ll int array[f];
        ll int fin[f];
        for(i = 0; i < f; i++) scanf("%lld", &array[i]);
        qsort(array, f, sizeof(ll int), cmp);
        i = 0;
        j = f - 1;
        fin[--d] = array[i];
        fin[--d] = array[j];
        i++; j--;
        while(j > i)
        {
            //if(array[j] < 0 )//array[j] - array[i] > array[i] - array[j])
            //{
                fin[--d] = array[j];
                fin[--d] = array[i];
            //}
           /* else
            {
                fin[--d] = array[j];
                fin[--d] = array[i];
           // }*/
            j--;
            i++;
        }
        printf("%lld", fin[0]);
        for(ll int i = 1; i < f; i++) printf(" %lld", fin[i]);
        printf("\n");
    }
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define ll long long
ll int cmp(void* a, void* b)
{
    return *((ll int*)a) - *((ll int*)b);
}
int main()
{
    ll int n, f, d, i, j, g;
    scanf("%lld", &n);
    while(n--)
    {
        scanf("%lld", &f);
        d = f;
        g = 1;
        ll int array[f];
        ll int fin[f];
        for(i = 0; i < f; i++) scanf("%lld", &array[i]);
        qsort(array, f, sizeof(ll int), cmp);
        i = 0;
        j = f - 1;
        fin[--d] = array[i];
        fin[--d] = array[j];
        i++; j--;
        while(j >= i)
        {
            //if(array[j] < 0 )//array[j] - array[i] > array[i] - array[j])
            //{
            if(g)
            {
                fin[--d] = array[j];
                fin[--d] = array[i];
                g = 0;
            }
            else
            {
                g = 1;
                fin[--d] = array[i];
                fin[--d] = array[j];
            }
           /* else
            {
                fin[--d] = array[j];
                fin[--d] = array[i];
           // }*/
            j--;
            i++;
        }
        printf("%lld", fin[0]);
        for(ll int i = 1; i < f; i++) printf(" %lld", fin[i]);
        printf("\n");
    }
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define ll long long
ll int cmp(void* a, void* b)
{
    return *((ll int*)a) - *((ll int*)b);
}
int main()
{
    ll int n, f, d, i, j, g;
    scanf("%lld", &n);
    while(n--)
    {
        scanf("%lld", &f);
        d = f;
        g = 1;
        ll int array[f];
        ll int fin[f];
        for(i = 0; i < f; i++) scanf("%lld", &array[i]);
        qsort(array, f, sizeof(ll int), cmp);
        i = 0;
        j = f - 1;
        fin[--d] = array[i];
        fin[--d] = array[j];
        i++; j--;
        while(j > i)
        {
            //if(array[j] < 0 )//array[j] - array[i] > array[i] - array[j])
            //{
            if(g)
            {
                fin[--d] = array[j];
                fin[--d] = array[i];
                g = 0;
            }
            else
            {
                g = 1;
                fin[--d] = array[i];
                fin[--d] = array[j];
            }
           /* else
            {
                fin[--d] = array[j];
                fin[--d] = array[i];
           // }*/
            j--;
            i++;
        }
        printf("%lld", fin[0]);
        for(ll int i = 1; i < f; i++) printf(" %lld", fin[i]);
        printf("\n");
    }
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
int f(const void *a, const void *b);

int main(){
    int test_cases;
    scanf("%d",&test_cases);
    int t;
    for(t=0; t<test_cases; t++){
        //TAKING INPUT
        int size;
        scanf("%d",&size);

        long long int array[100000], answer[100000];
        int j1;
        for(j1=0; j1<size; j1++) scanf("%d",&array[j1]);

        //MAIN ALGORITHM
        qsort(array, size, sizeof(long long int), f);
        if(size%2==0){
            int k1=0, k2=size-1;
            for(j1=size-1; j1>=0; j1--){
                answer[j1] = array[k2];
                k2--;
                j1--;
                answer[j1] = array[k1];
                k1++;
            }
        }
        else{
            answer[0] = array[( (size-1) /2)+1];
            int k1=0, k2=size-1;
            for(j1=size-1; j1>1; j1--){
                answer[j1] = array[k2];
                k2--;
                j1--;
                answer[j1] = array[k1];
                k1++;
            }
        }

        //PRINTING OUTPUT
        for(j1=0; j1<size; j1++) printf("%d ",answer[j1]);
    }
return 0;
}

int f(const void *a, const void *b){
return ( *(int*)a-*(int*)b );
}


#include <stdio.h>
#include <stdlib.h>
int f(const void *a, const void *b);

int main(){
    int test_cases;
    scanf("%d",&test_cases);
    int t;
    for(t=0; t<test_cases; t++){
        //TAKING INPUT
        int size;
        scanf("%d",&size);

        long long int array[100000], answer[100000];
        int j1;
        for(j1=0; j1<size; j1++) scanf("%d",&array[j1]);

        //MAIN ALGORITHM
        qsort(array, size, sizeof(long long int), f);
        if(size%2==0){
            int k1=0, k2=size-1;
            for(j1=size-1; j1>=0; j1--){
                answer[j1] = array[k2];
                k2--;
                j1--;
                answer[j1] = array[k1];
                k1++;
            }
        }
        else{
            answer[0] = array[(size/2) + 1];
            int k1=0, k2=size-1;
            for(j1=size-1; j1>0; j1--){
                answer[j1] = array[k2];
                k2--;
                j1--;
                answer[j1] = array[k1];
                k1++;
            }
        }

        //PRINTING OUTPUT
        for(j1=0; j1<size; j1++) printf("%d ",answer[j1]);
    }
return 0;
}

int f(const void *a, const void *b){
return ( *(int*)a-*(int*)b );
}


#include <stdio.h>
#include <stdlib.h>
int f(const void *a, const void *b);

int main(){
    int test_cases;
    scanf("%d",&test_cases);
    int t;
    for(t=0; t<test_cases; t++){
        //TAKING INPUT
        int size;
        scanf("%d",&size);

        long long int array[100000], answer[100000];
        int j1;
        for(j1=0; j1<size; j1++) scanf("%d",&array[j1]);

        //MAIN ALGORITHM
        qsort(array, size, sizeof(long long int), f);
        if(size%2==0){
            int k1=0, k2=size-1;
            for(j1=size-1; j1>=0; j1--){
                answer[j1] = array[k2];
                k2--;
                j1--;
                answer[j1] = array[k1];
                k1++;
            }
        }
        else{
            answer[0] = array[( (size-1) /2 )];
            int k1=0, k2=size-1;
            for(j1=size-1; j1>1; j1--){
                answer[j1] = array[k2];
                k2--;
                j1--;
                answer[j1] = array[k1];
                k1++;
            }
        }

        //PRINTING OUTPUT
        for(j1=0; j1<size; j1++) printf("%d ",answer[j1]);
    }
return 0;
}

int f(const void *a, const void *b){
return ( *(int*)a-*(int*)b );
}


#include <stdio.h>
#include <stdlib.h>
int f(const void *a, const void *b);

int main(){
    int test_cases;
    scanf("%d",&test_cases);
    int t;
    for(t=0; t<test_cases; t++){
        //TAKING INPUT
        int size;
        scanf("%d",&size);

        long long int array[100000], answer[100000];
        int j1;
        for(j1=0; j1<size; j1++) scanf("%d",&array[j1]);

        //MAIN ALGORITHM
        qsort(array, size, sizeof(long long int), f);
        if(size%2==0){
            int k1=0, k2=size-1;
            for(j1=size-1; j1>=0; j1--){
                answer[j1] = array[k2];
                k2--;
                j1--;
                answer[j1] = array[k1];
                k1++;
            }
        }
        else{
            answer[0] = array[(size-1/2)+1];
            int k1=0, k2=size-1;
            for(j1=size-1; j1>1; j1--){
                answer[j1] = array[k2];
                k2--;
                j1--;
                answer[j1] = array[k1];
                k1++;
            }
        }

        //PRINTING OUTPUT
        for(j1=0; j1<size; j1++) printf("%d ",answer[j1]);
    }
return 0;
}

int f(const void *a, const void *b){
return ( *(int*)a-*(int*)b );
}


#include <stdio.h>
#include <stdlib.h>
int f(const void *a, const void *b);

int main(){
    int test_cases;
    scanf("%d",&test_cases);
    int t;
    for(t=0; t<test_cases; t++){
        //TAKING INPUT
        int size;
        scanf("%d",&size);

        long long int array[100000], answer[100000];
        int j1;
        for(j1=0; j1<size; j1++) scanf("%d",&array[j1]);

        //MAIN ALGORITHM
        qsort(array, size, sizeof(long long int), f);
        if(size%2==0){
            int k1=0, k2=size-1;
            for(j1=size-1; j1>=0; j1--){
                answer[j1] = array[k2];
                k2--;
                j1--;
                answer[j1] = array[k1];
                k1++;
            }
        }
        else{
            answer[0] = array[(size/2) + 1];
            int k1=0, k2=size-1;
            for(j1=size-1; j1>1; j1--){
                answer[j1] = array[k2];
                k2--;
                j1--;
                answer[j1] = array[k1];
                k1++;
            }
        }

        //PRINTING OUTPUT
        for(j1=0; j1<size; j1++) printf("%d ",answer[j1]);
    }
return 0;
}

int f(const void *a, const void *b){
return ( *(int*)a-*(int*)b );
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int mod(int n){
  if(n>0)
   return n;
  else return -n;
}
void merge(int arr[], int l, int m, int r);
void mergeSort(int arr[], int l, int r)
{
    if (l<r){
        int m = (l+r)/2;
        mergeSort(arr,l,m);
        mergeSort(arr,m+1,r);
        merge(arr,l,m,r);
    }
}

void merge(int arr[], int l, int m, int r)
{
    int i,j,k;
    int n1 = m - l + 1;
    int n2 = r - m;
    int L[n1], R[n2];
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1 + j];

    i = 0;j = 0;k = l;
    while (i < n1 && j < n2) {
        if (L[i] <= R[j]) {
            arr[k++] = L[i++];
        }
        else {
            arr[k++] = R[j++];
        }
    }
    /* Copy the remaining elements of L[], if there are any */
    while (i<n1) {
        arr[k++] = L[i++];
    }
    /* Copy the remaining elements of R[], if there are any */
    while (j<n2) {
        arr[k++] = R[j++];
    }
  }

int swap(int *a,int *b)
{
  int t;
  t=*a;
  *a=*b;
  *b=t;
}

void main(){
  int n,t,a[100000],b[100000];
  scanf("%d",&t);
  while (t--) {
    int j=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    mergeSort(a,0,n-1);
    int k=n;
        if(n%2!=0){
          printf("%d ",a[n/2]);
          for(int i=1;i<=n/2;i++){
            printf("%d ",a[n/2+i]);
            printf("%d ",a[n/2-i]);
            }
          }
          else{
              for(int i=1;i<=n/2;i++){
                printf("%d ",a[n/2-i]);
                printf("%d ",a[n/2-1+i]);
              }
            }

    printf("\n");
  }
}


#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>

int compare( const void* a, const void* b)
{
     int int_a = * ( (int*) a );
     int int_b = * ( (int*) b );

     if ( int_a == int_b ) return 0;
     else if ( int_a < int_b ) return -1;
     else return 1;
}

void tri(int T[],int n)
{
    qsort( T, n, sizeof(int), compare );

    int G[n];
    int k=0;
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            G[i] = T[k];
        }else
        {
            G[i] = T[n-k-1];
            k++;
        }

    }
    for(int i=0;i<n;i++)
    {
        printf("%d ",G[n-i-1]);
    }

}
void clear_input_buffer(void) {
    int ch;
    while (((ch = getchar()) != EOF) && (ch != '\n')) /* void */;

}
int main()
{

  int t;
  scanf("%d",&t);
  int lengths[t];
  int* cells[t];
  for(int i=0;i<t;i++)
  {

      int n;
      scanf("%d",&n);
      lengths[i] = n;
      cells[i] = malloc(n*sizeof(int));
      for(int j=0;j<n;j++)
      {
        scanf("%d ",&cells[i][j]);
      }

  }

  for(int i=0;i<t;i++)
  {
      tri(cells[i],lengths[i]);
      printf("\n");
  }
  return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>

typedef struct cellule
{
    int val;
    int smallest;
}cellule;
typedef struct cellule* header;
/*header add(header head,int val)
{
    if(head==NULL)
    {
        cellule* m = malloc(sizeof(cellule));
        m->val = val;
        m->smallest = -1;
        m->next = NULL;
        head = m;

    }else
    {
        cellule* m = malloc(sizeof(cellule));
        m->val = val;
        m->smallest = -1;
        m->next = NULL;
        cellule* searcher = head;
        while(searcher->next!=NULL)searcher=searcher->next;
        searcher->next = m;
    }
    return head;
}*/
int get_smallest(header* T[],int i,int j,int n)
{
    printf("am in get_smallest\n");
    int s = abs(T[i][0]->val - T[i][1]->val);
    printf("%d",s);

    for(int k=0;k<n;k++)
    {
        if(abs(T[i][j]->val - T[i][k]->val)<s && j!=k)s=abs(T[i][j]->val - T[i][k]->val);
    }
    return s;
}
void tri(header* T[],int i,int n)
{
    bool do_permute = true;
    while(do_permute)
    {
        do_permute = false;
        for(int k=0;k<n-1;k++)
        {
            if(T[i][k]->smallest>T[i][k+1]->smallest)
            {
                int p = T[i][k]->val;
                T[i][k]->val = T[i][k+1]->val;
                T[i][k+1]->val = p;
                int s = T[i][k]->smallest;
                T[i][k]->smallest = T[i][k+1]->smallest;
                T[i][k+1]->smallest = s;
                do_permute = true;
            }
        }
    }
    for(int k=0;k<n;k++)printf("%d",T[i][k]->val);
}
void main()
{

    int t;
    scanf("%d",&t);
    header* T[t];
    int n;
    int lengths[t];
    for(int i=0;i<t;i++)
    {
        scanf("%d",&n);
        lengths[i] = n;
        cellule* Elements[n];

        char* mystring = malloc(n*sizeof(char));
        scanf("%s",mystring);
        for(int j=0;j<2*n;j=j+2)
        {
            cellule* m = malloc(sizeof(cellule)) ;
            m->val = atoi(&(mystring[j]));
            m->smallest = NULL;
            Elements[j/2] = m;
        }
        T[i] = Elements;

    }
    printf("am out");

    for(int i=0;i<t;i++)
    {

        for(int j=0;j<lengths[i];j++)
        {
                printf("am in");

                T[i][j]->smallest = get_smallest(T,i,j,lengths[i]);
                printf("am out again");

        }
        printf("am out finally");
        tri(T,i,lengths[i]);
    }

    //show(first);
    int i = 0;
    printf("first[0] = %d",T[i][0]->val);
}


#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>

typedef struct cellule
{
    long  val;
    long  smallest;
    struct cellule* next;
}cellule;
typedef struct cellule* header;
int get_smallest(cellule* T,cellule* tracker,int index,int length)
{
    int s;
    if(tracker->next!=NULL)
    {
        s = abs(tracker->val - tracker->next->val);
    }else
    {
        s = abs(T->val - tracker->val);
    }
    cellule* nigga=T;
    int j = 0;
    while(nigga!=NULL)
    {
        if(abs(nigga->val - tracker->val)<s && j!=index)s=abs(nigga->val - tracker->val);
        nigga = nigga->next;
        j++;
    }
    return s;
}
void tri(header T,int n)
{
    bool do_permute = true;
    while(do_permute)
    {
        header tracker = T;
        do_permute = false;
        for(int k=0;k<n-1;k++)
        {
            if(tracker->smallest>tracker->next->smallest)
            {
                int p = tracker->val;
                tracker->val = tracker->next->val;
                tracker->next->val = p;
                int s = tracker->smallest;
                tracker->smallest = tracker->next->smallest;
                tracker->next->smallest = s;
                do_permute = true;
            }
            tracker = tracker->next;
        }
    }
    header tracker = T;
    while(tracker!=NULL)
    {
        printf("%d ",tracker->val);
        tracker = tracker->next;
    }

}
void clear_input_buffer(void) {
    int ch;
    while (((ch = getchar()) != EOF) && (ch != '\n')) /* void */;

}
int main()
{

  int t;
  scanf("%d",&t);
  int lengths[t];
  char* lines[t];
  cellule* cells[t];
  for(int i=0;i<t;i++)
  {
      clear_input_buffer();
      int n;
      scanf("%d",&n);
      clear_input_buffer();
      lengths[i] = n;
      char* mystr = malloc((2*n+1)*sizeof(char));
      fgets(mystr,(2*n+1)*sizeof(char),stdin);
      char* endptr;
      cellule* m = malloc(sizeof(cellule));
      m->next = NULL;
      m->val = strtol(mystr,&endptr,10);
      m->smallest = 0;
      cells[i] = m;
      cellule* tracker = m;
      int k = 0;
      while(mystr!=endptr && k!=n-1)
      {
          mystr = endptr;
          cellule* a = malloc(sizeof(cellule));
          a->next = NULL;
          a->val = strtol(mystr,&endptr,10);
          a->smallest = 0;
          tracker->next = a;
          tracker = a;
          k++;
      }

  }
  for(int i=0;i<t;i++)
  {
      cellule* tracker = cells[i];
      int j=0;
      while(tracker!=NULL)
      {
          tracker->smallest = get_smallest(cells[i],tracker,j,lengths[i]);
          tracker = tracker->next;
          j++;
      }
  }
  for(int i=0;i<t;i++)
  {
      tri(cells[i],lengths[i]);
      printf("\n");
  }
  return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>

typedef struct cellule
{
    long  val;
    long  smallest;
}cellule;
typedef struct cellule* header;
int get_smallest(cellule T[],int index,int length)
{
    int s = abs(T[index].val - T[abs(index-1)].val);;
    int j = 0;
    while(j<length)
    {
        if(abs(T[j].val - T[index].val)<s && j!=index)s=abs(T[j].val - T[index].val);
        j++;
    }
    return s;
}
void tri(cellule T[],int n)
{
    bool do_permute = true;
    while(do_permute)
    {
        do_permute = false;
        for(int k=0;k<n-1;k++)
        {
            if(T[k].smallest>T[k+1].smallest)
            {
                int p = T[k].val;
                T[k].val = T[k+1].val;
                T[k+1].val = p;
                int s = T[k].smallest;
                T[k].smallest = T[k+1].smallest;
                T[k+1].smallest = s;
                do_permute = true;
            }

        }
    }
    for(int i=0;i<n;i++)
    {
        printf("%ld ",T[i].val);

    }

}
void clear_input_buffer(void) {
    int ch;
    while (((ch = getchar()) != EOF) && (ch != '\n')) /* void */;

}
int main()
{

  int t;
  scanf("%d",&t);
  int lengths[t];
  cellule* cells[t];
  for(int i=0;i<t;i++)
  {
      clear_input_buffer();
      int n;
      scanf("%d",&n);
      clear_input_buffer();
      lengths[i] = n;
      char* mystr = malloc((2*n+1)*sizeof(char));
      fgets(mystr,(2*n+1)*sizeof(char),stdin);
      char* endptr;
      cells[i] = malloc(n*sizeof(cellule));
      cellule m;
      m.val = strtol(mystr,&endptr,10);
      m.smallest = 0;
      cells[i][0] = m;
      int k = 1;
      while(mystr!=endptr && k!=n)
      {
          mystr = endptr;
          cellule a;
          a.val = strtol(mystr,&endptr,10);
          a.smallest = 0;
          cells[i][k]= a;
          k++;
      }

  }

  for(int i=0;i<t;i++)
  {
      for(int j=0;j<lengths[i];j++)
      {
          cells[i][j].smallest = get_smallest(cells[i],j,lengths[i]);

      }
  }

  for(int i=0;i<t;i++)
  {
      tri(cells[i],lengths[i]);
      printf("\n");
  }
  return 0;
}


#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>

void tri(int T[],int n)
{
    bool do_permute = true;
    while(do_permute)
    {
        do_permute = false;
        for(int k=0;k<n-1;k++)
        {
            if(T[k]>T[k+1])
            {
                int p = T[k];
                T[k] = T[k+1];
                T[k+1] = p;
                do_permute = true;
            }

        }
    }
    for(int i=0;i<n;i++)
    {
        printf("%d ",T[i]);

    }
    printf("\n");
    int G[n];
    int k=0;
    for(int i=0;i<n-1;i+=2)
    {

            G[i] = T[k];
            G[i+1] = T[n-k-1];
            k++;

    }
    for(int i=0;i<n;i++)
    {
        printf("%d ",G[n-i-1]);
    }

}
void clear_input_buffer(void) {
    int ch;
    while (((ch = getchar()) != EOF) && (ch != '\n')) /* void */;

}
int main()
{

  int t;
  scanf("%d",&t);
  int lengths[t];
  int* cells[t];
  for(int i=0;i<t;i++)
  {
      clear_input_buffer();
      int n;
      scanf("%d",&n);
      clear_input_buffer();
      lengths[i] = n;
      char* mystr = malloc((2*n+1)*sizeof(char));
      fgets(mystr,(2*n+1)*sizeof(char),stdin);
      char* endptr;
      cells[i] = malloc(n*sizeof(int));

      cells[i][0] = strtol(mystr,&endptr,10);
      int k = 1;
      while(mystr!=endptr && k!=n)
      {
          mystr = endptr;

          cells[i][k]= strtol(mystr,&endptr,10);
            k++;
      }

  }

  for(int i=0;i<t;i++)
  {
      tri(cells[i],lengths[i]);
      printf("\n");
  }
  return 0;
}


#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <sstream>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <numeric>
using namespace std;

#define mp              make_pair
#define pb              push_back
#define sz(x)           ((x).size())
#define For(i,a,b)      for(int i=(a);i<(b);++i)
#define rep(i,n)        For(i,0,(n))
#define all(v)          (v).begin(),(v).end()

int main( void )
{
    string      s, t;

    getline( cin, s );
    getline( cin, t );

    vector<vector<int> >    v( sz( t ) + 1, vector<int>( sz( s ) + 1, 0 ) );

    rep( i, sz( t ) + 1 )
        v[i][0] = i;

    rep( i, sz( s ) + 1 )
        v[0][i] = i;

    For( i, 1, sz( t ) + 1 ) {
        For( j, 1, sz( s ) + 1 ) {
            v[i][j] = min( v[i-1][j] + 1, min( v[i][j-1] + 1, t[i-1] == s[j-1] ? v[i-1][j-1] : v[i-1][j-1] + 1 ) );
        }
    }

    cout << v[sz(t)][sz(s)] << endl;

    int     spos = sz( s ), tpos = sz( t );

    rep( i, v[sz(t)][sz(s)] ) {
        int     up, left, dig;
        up = tpos > 0 ? v[tpos-1][spos] : 98765432;
        left = spos > 0 ? v[tpos][spos-1] : 98765432;
        dig = tpos > 0 && spos > 0 ? v[tpos-1][spos-1] : 98765432;

        if( dig <= up && dig <= left ) {
            if( dig != v[tpos][spos] )
                cout << "REPLACE " << spos << " " << t[tpos-1] << endl;
            else
                --i;
            tpos--;
            spos--;
        } else if( up <= left && up <= dig ) {
            cout << "INSERT " << spos + 1 << " " << t[tpos-1] << endl;
            tpos--;
        } else {
            cout << "DELETE " << spos << " " << s[spos-1] << endl;
            spos--;
        }
    }
}


#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <sstream>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <numeric>
using namespace std;

#define mp              make_pair
#define pb              push_back
#define sz(x)           ((x).size())
#define For(i,a,b)      for(int i=(a);i<(b);++i)
#define rep(i,n)        For(i,0,(n))
#define all(v)          (v).begin(),(v).end()

int main( void )
{
    string      s, t;

    getline( cin, s );
    getline( cin, t );

    vector<vector<int> >    v( sz( t ) + 1, vector<int>( sz( s ) + 1, 0 ) );

    rep( i, sz( t ) + 1 )
        v[i][0] = i;

    rep( i, sz( s ) + 1 )
        v[0][i] = i;

    For( i, 1, sz( t ) + 1 ) {
        For( j, 1, sz( s ) + 1 ) {
            v[i][j] = min( v[i-1][j] + 1, min( v[i][j-1] + 1, t[i-1] == s[j-1] ? v[i-1][j-1] : v[i-1][j-1] + 1 ) );
        }
    }

    cout << v[sz(t)][sz(s)] << endl;

    int     spos = sz( s ), tpos = sz( t );

    rep( i, v[sz(t)][sz(s)] ) {
        int     up, left, dig;
        up = tpos > 0 ? v[tpos-1][spos] : 98765432;
        left = spos > 0 ? v[tpos][spos-1] : 98765432;
        dig = tpos > 0 && spos > 0 ? v[tpos-1][spos-1] : 98765432;

        if( dig <= up && dig <= left ) {
            if( dig != v[tpos][spos] )
                cout << "REPLACE " << spos << " " << t[tpos-1] << endl;
            else
                --i;
            tpos--;
            spos--;
        } else if( up <= left && up <= dig ) {
            cout << "INSERT " << spos + 1 << " " << t[tpos-1] << endl;
            tpos--;
        } else {
            cout << "DELETE " << spos << " " << t[tpos] << endl;
            spos--;
        }
    }
}