#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <cstring>
using namespace std;

string remove_dot(const char *p)
{
    const char *dot = strchr(p, '.');
    return dot ? string(p, dot - p) : string(p);
}

bool compare_filenames(string a, string b)
{
    char *pA, *pB;
    long A = strtol(a.c_str(), &pA, 10),
         B = strtol(b.c_str(), &pB, 10);
    if (A < B)
        return true;
    if (A == B)
        return remove_dot(pA) < remove_dot(pB);
    return false;
}

int main(int, char **)
{
    const char *v[] ={
        "a10",
        "10a",
        "1ab",
        "2a",
        "1aa",
        "a2",
        "1bb",
        "1a",
        "a1",
        "1b",
        "10b",
        "2b",
        "b1",
        "b10"
    };
    vector<string> t(v, v+(sizeof(v)/sizeof(char*)));
    sort(t.begin(), t.end(), compare_filenames);
    copy(t.begin(), t.end(), ostream_iterator<string>(cout, "\n"));
    return 0;
}