Cost basis uses the First In, First Out method. I.e., the oldest shares in your portfolio will be “sold” first.