orthehelper
orthehelper

Reputation: 4079

How to sort NSMutableDictionary

i am using NSMutableDictionary tho hold data and load it to a UITableview, this is how the dictionary looks like :

    041517ba8e0542b14e96469d87bba694b42db15a =     (
    "{\n    size             = {360, 480}\n    CGImage.size     = {480, 360}\n    imageOrientation = UIImageOrientationRight\n}",
    041517ba8e0542b14e96469d87bba694b42db15a,
    "2012-10-10 10:17:13 +0000"
);
3582a7ee9ce2e232704c3e51f27bdc9274e965c6 =     (
    "{\n    size             = {360, 480}\n    CGImage.size     = {480, 360}\n    imageOrientation = UIImageOrientationRight\n}",
    3582a7ee9ce2e232704c3e51f27bdc9274e965c6,
    "2012-10-10 10:12:57 +0000",
    "Plastic Cup"
);
3ce8b24a9da8916f2d669f625c9eb28e77b710ec =     (
    "{\n    size             = {360, 480}\n    CGImage.size     = {480, 360}\n    imageOrientation = UIImageOrientationRight\n}",
    3ce8b24a9da8916f2d669f625c9eb28e77b710ec,
    "2012-10-10 10:12:48 +0000",
    Headphones
);
9a2fd3bbd741e52cfc31d2a341ab79241c3048db =     (
    "{\n    size             = {360, 480}\n    CGImage.size     = {480, 360}\n    imageOrientation = UIImageOrientationRight\n}",
    9a2fd3bbd741e52cfc31d2a341ab79241c3048db,
    "2012-10-10 10:11:58 +0000",
    "Men's Wrist Watch"
);
b7b8646cb8548e6c8cc1c83b90b9d8d3b265ed5b =     (
    "{\n    size             = {360, 480}\n    CGImage.size     = {480, 360}\n    imageOrientation = UIImageOrientationRight\n}",
    b7b8646cb8548e6c8cc1c83b90b9d8d3b265ed5b,
    "2012-10-10 10:14:46 +0000",
    Dog
);
c30fe8901a4e14da415981ade707330bda85c2bf =     (
    "{\n    size             = {360, 480}\n    CGImage.size     = {480, 360}\n    imageOrientation = UIImageOrientationRight\n}",
    c30fe8901a4e14da415981ade707330bda85c2bf,
    "2012-10-10 10:14:32 +0000",
    "Dog Olive"
);
d47987a197cc9b383921ef021d5469cd69e02dec =     (
    "{\n    size             = {360, 480}\n    CGImage.size     = {480, 360}\n    imageOrientation = UIImageOrientationRight\n}",
    d47987a197cc9b383921ef021d5469cd69e02dec,
    "2012-10-10 10:12:24 +0000",
    Blurry
);
d8363eb358ce8a6266d9dae37b19628d8be8e604 =     (
    "{\n    size             = {360, 480}\n    CGImage.size     = {480, 360}\n    imageOrientation = UIImageOrientationRight\n}",
    d8363eb358ce8a6266d9dae37b19628d8be8e604,
    "2012-10-10 10:13:08 +0000",
    "Analog Wristwatch"
);
e849e2f6d45a787fff42486cd8cb4d45499b2ef4 =     (
    "{\n    size             = {360, 480}\n    CGImage.size     = {480, 360}\n    imageOrientation = UIImageOrientationRight\n}",
    e849e2f6d45a787fff42486cd8cb4d45499b2ef4,
    "2012-10-10 10:15:14 +0000",
    "Red Sports Car"
);
f0c5598cd2a5314d64bd25dffbef2c98be78ac0f =     (
    "{\n    size             = {360, 480}\n    CGImage.size     = {480, 360}\n    imageOrientation = UIImageOrientationRight\n}",
    f0c5598cd2a5314d64bd25dffbef2c98be78ac0f,
    "2012-10-10 10:12:40 +0000",
    "Laptop Computer Keyboard"
);

it contain a photos but not by order (added to the dictionary) what i want is to draw the UITableView by the order this photos are added.

any idea?

Upvotes: 0

Views: 336

Answers (2)

Fogmeister
Fogmeister

Reputation: 77621

A dictionary is an unsorted collection.

You should really look at putting the dictionaries or just the keys into an array.

Then you can use the array for sorting and the keys to reference the dictionary.

Upvotes: 2

Andrey Chernukha
Andrey Chernukha

Reputation: 21808

use NSMutableArray for keys and add a key to that NSMutableArray each time you add photo to the dictionary. The array will keep order

Upvotes: 1

Related Questions